New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iphone safari connected with longPolling does not download images #1406

Closed
redware opened this Issue Jan 24, 2013 · 60 comments

Comments

Projects
None yet
@redware

redware commented Jan 24, 2013

I have an application working well (using a hub) but the iphone downloading symbol in safari continuously displays. I understand this is because it is not using websockets and I can only get serversideevents and longpolling to work when I change the start settings for the hub. It would not be so great a problem except this seems to stop images downloading on the browser. I am using jquery mobile and have it hosted on windowsazure. Desktop browsers working fine with images.

--- Uploaded RC2 and have same problem ... with longpolling the iphone safari downloading sign shows continuously and when using jquery mobile - images are not showing up unless they have bee viewed before,

@aerlijman

This comment has been minimized.

Show comment
Hide comment
@aerlijman

aerlijman Feb 27, 2013

I am having the same behaviour with iOS. With SignalR 1.0.0 final, I can chat (that is my app) but no images are displayed in my app. After removing the SignarR, I get images. However, in Android, I see the images but my SignalR code does not work. Any solution for this?

aerlijman commented Feb 27, 2013

I am having the same behaviour with iOS. With SignalR 1.0.0 final, I can chat (that is my app) but no images are displayed in my app. After removing the SignarR, I get images. However, in Android, I see the images but my SignalR code does not work. Any solution for this?

@redware

This comment has been minimized.

Show comment
Hide comment
@redware

redware Feb 27, 2013

I ended up turning off signalR when the page was displayed and then turning it on again which gave the browser time to display the images. I think it is a problem and am hoping that it is because signalr is not using websockets in my case. I am hoping that an upgrade to the web server will allow it to use websockets and cure the ptoblem. Alternatively it may be a clash with jquery mobile on the iphone (IOS6).

redware commented Feb 27, 2013

I ended up turning off signalR when the page was displayed and then turning it on again which gave the browser time to display the images. I think it is a problem and am hoping that it is because signalr is not using websockets in my case. I am hoping that an upgrade to the web server will allow it to use websockets and cure the ptoblem. Alternatively it may be a clash with jquery mobile on the iphone (IOS6).

@aerlijman

This comment has been minimized.

Show comment
Hide comment
@aerlijman

aerlijman Feb 27, 2013

I hard coded longpolling and got it working in Android. In iPhone some images are displayed and some other don't. It like your problem. So a few questions:

  1. How did you turn it off and on?
  2. About the upgrade to the web server.. you are saying that ios does not use websockets because your server and not iOS support? As I manage the server.. should I be able to control that? Are you talking about forcing to websockets on login or what?

thx for your reply.

aerlijman commented Feb 27, 2013

I hard coded longpolling and got it working in Android. In iPhone some images are displayed and some other don't. It like your problem. So a few questions:

  1. How did you turn it off and on?
  2. About the upgrade to the web server.. you are saying that ios does not use websockets because your server and not iOS support? As I manage the server.. should I be able to control that? Are you talking about forcing to websockets on login or what?

thx for your reply.

@redware

This comment has been minimized.

Show comment
Hide comment
@redware

redware Feb 27, 2013

I just used the pagecreate and pageshow events in jquery mobile to turn signalr on and off. This is a kludge because there is a small time where signalr is not working on the client. This releases safari on the iphone to display the images. I do not know if it is a jquery mobile problem or a long polling problem but the problem is only on the iphone (IOS6).

I am using IIS on azure so it is Windows Server 2008. Apparently only IIS8 on Windows Server 2012 supports websockets so signalr is long polling.

  if (SBIsIphoneOrIpad() == true) {
    $('#div_snogbox_settings').live('pagecreate', function (event) {
        SBChatConnectionStop();
    });

    $('#div_snogbox_settings').live('pageshow', function (event) {
        SBChatConnectionStart();
    });
}

function SBChatConnectionStart() {
if (chat != null) {
$.connection.hub.start().done(function () {
// Logon to the chat server
// SBShowMessage("Connected to Chat Server 49!");
SBChatSendLogon();
}).fail(function () {
SBShowMessage("Could not connect to Chat Server 50 !");
chat = null;
});
}
}

function SBChatConnectionStop() {
if (chat != null) {
$.connection.hub.stop();
/SBShowMessage("Chat Server Connection stopped !");/
}
}

redware commented Feb 27, 2013

I just used the pagecreate and pageshow events in jquery mobile to turn signalr on and off. This is a kludge because there is a small time where signalr is not working on the client. This releases safari on the iphone to display the images. I do not know if it is a jquery mobile problem or a long polling problem but the problem is only on the iphone (IOS6).

I am using IIS on azure so it is Windows Server 2008. Apparently only IIS8 on Windows Server 2012 supports websockets so signalr is long polling.

  if (SBIsIphoneOrIpad() == true) {
    $('#div_snogbox_settings').live('pagecreate', function (event) {
        SBChatConnectionStop();
    });

    $('#div_snogbox_settings').live('pageshow', function (event) {
        SBChatConnectionStart();
    });
}

function SBChatConnectionStart() {
if (chat != null) {
$.connection.hub.start().done(function () {
// Logon to the chat server
// SBShowMessage("Connected to Chat Server 49!");
SBChatSendLogon();
}).fail(function () {
SBShowMessage("Could not connect to Chat Server 50 !");
chat = null;
});
}
}

function SBChatConnectionStop() {
if (chat != null) {
$.connection.hub.stop();
/SBShowMessage("Chat Server Connection stopped !");/
}
}

@aerlijman

This comment has been minimized.

Show comment
Hide comment
@aerlijman

aerlijman Feb 28, 2013

Thx for that code!
Very interesting, but I have many pages and can not do that for all of them. Are you sure messages are lost? Do signalR queue them and if you reconnect you get them? I am thinking of developing myself a poll - queue system because this does not work well in iOS 6, but was wondering if signalR can be configured to be normal poll instead of long poll. Ideas?

aerlijman commented Feb 28, 2013

Thx for that code!
Very interesting, but I have many pages and can not do that for all of them. Are you sure messages are lost? Do signalR queue them and if you reconnect you get them? I am thinking of developing myself a poll - queue system because this does not work well in iOS 6, but was wondering if signalR can be configured to be normal poll instead of long poll. Ideas?

@redware

This comment has been minimized.

Show comment
Hide comment
@redware

redware Mar 1, 2013

It is v. annoying. All desktop browsers work fine. The problem may be confined to Safari on IOS. My solution is definately a kludge to get the solution working. I have not verified if it is cause by the interaction of signalr and jquery mobile (jquery mobile loads pages with hijax) or whether the problem is because of long polling. It is also not clear that signalr will only use websockets with windows server 2012 and I am hoping this might be a resolution. I will update when I discover a solution but I have put that project to bed now for a while. NB - if you are using jquery you could attach those events to all pages quite easily.....(but it is still a bad solution!).

I have reported this as an issue so see what happens with future releases....

redware commented Mar 1, 2013

It is v. annoying. All desktop browsers work fine. The problem may be confined to Safari on IOS. My solution is definately a kludge to get the solution working. I have not verified if it is cause by the interaction of signalr and jquery mobile (jquery mobile loads pages with hijax) or whether the problem is because of long polling. It is also not clear that signalr will only use websockets with windows server 2012 and I am hoping this might be a resolution. I will update when I discover a solution but I have put that project to bed now for a while. NB - if you are using jquery you could attach those events to all pages quite easily.....(but it is still a bad solution!).

I have reported this as an issue so see what happens with future releases....

@aerlijman

This comment has been minimized.

Show comment
Hide comment
@aerlijman

aerlijman Mar 1, 2013

Good news here... After chatting with the people from signalR, I could understand how to configure a long polling system to be like a simple polling system, where I check for events and disconnect. So I leave time to get images. Just add this code in the global asax. This will make the connection live for 1 sec and try to get new events every 5 secs. What do you think?

protected void Application_Start()
{

        GlobalHost.Configuration.ConnectionTimeout = TimeSpan.FromSeconds(1);
        Microsoft.AspNet.SignalR.Transports.LongPollingTransport.LongPollDelay = 5000;
        RouteTable.Routes.MapHubs();

aerlijman commented Mar 1, 2013

Good news here... After chatting with the people from signalR, I could understand how to configure a long polling system to be like a simple polling system, where I check for events and disconnect. So I leave time to get images. Just add this code in the global asax. This will make the connection live for 1 sec and try to get new events every 5 secs. What do you think?

protected void Application_Start()
{

        GlobalHost.Configuration.ConnectionTimeout = TimeSpan.FromSeconds(1);
        Microsoft.AspNet.SignalR.Transports.LongPollingTransport.LongPollDelay = 5000;
        RouteTable.Routes.MapHubs();
@Jazaret

This comment has been minimized.

Show comment
Hide comment
@Jazaret

Jazaret Mar 28, 2013

aerlijman, thank you for your help and input but I tried this and still get missing images.

Jazaret commented Mar 28, 2013

aerlijman, thank you for your help and input but I tried this and still get missing images.

@aerlijman

This comment has been minimized.

Show comment
Hide comment
@aerlijman

aerlijman Mar 28, 2013

Maybe I can help...
Did you try it with 1.0.1 and ios6?
Vs.2012 or vs2010?
Are you using jquery mobile 1.2 or which one?

aerlijman commented Mar 28, 2013

Maybe I can help...
Did you try it with 1.0.1 and ios6?
Vs.2012 or vs2010?
Are you using jquery mobile 1.2 or which one?

@aerlijman

This comment has been minimized.

Show comment
Hide comment
@aerlijman

aerlijman Mar 28, 2013

ah..and are you forcing longPolling on client side like this ?

    $.connection.hub.logging = true;
    $.connection.hub.start({ transport: 'longPolling' }).done(function (myHubConnection) {

    });

aerlijman commented Mar 28, 2013

ah..and are you forcing longPolling on client side like this ?

    $.connection.hub.logging = true;
    $.connection.hub.start({ transport: 'longPolling' }).done(function (myHubConnection) {

    });
@Jazaret

This comment has been minimized.

Show comment
Hide comment
@Jazaret

Jazaret Mar 28, 2013

Right now I tried on 1.0.0, ios6, vs2010 and jquery 1.7.2. I didn't set the logging or transport I will try that and 1.0.1. Thanks for the quick feedback.

Jazaret commented Mar 28, 2013

Right now I tried on 1.0.0, ios6, vs2010 and jquery 1.7.2. I didn't set the logging or transport I will try that and 1.0.1. Thanks for the quick feedback.

@ghost ghost assigned Xiaohongt Mar 29, 2013

@davidfowl

This comment has been minimized.

Show comment
Hide comment
@davidfowl

davidfowl Mar 29, 2013

Member

@Xiaohongt can you take a look at this one?

Member

davidfowl commented Mar 29, 2013

@Xiaohongt can you take a look at this one?

@Jazaret

This comment has been minimized.

Show comment
Hide comment
@Jazaret

Jazaret Mar 30, 2013

@aerlijman your solution seems to have worked. I upgraded to 1.0.1 and force longPolling for iOS safari browsers and it works and grabs images after page load. Thanks!

Jazaret commented Mar 30, 2013

@aerlijman your solution seems to have worked. I upgraded to 1.0.1 and force longPolling for iOS safari browsers and it works and grabs images after page load. Thanks!

@aerlijman

This comment has been minimized.

Show comment
Hide comment
@aerlijman

aerlijman Mar 31, 2013

Great. The next improvement I will do here is to add a jquery plug in to delay the loading of the images and see what happens. You should try it too if you have long lists with images I think.
Good luck

aerlijman commented Mar 31, 2013

Great. The next improvement I will do here is to add a jquery plug in to delay the loading of the images and see what happens. You should try it too if you have long lists with images I think.
Good luck

@redware

This comment has been minimized.

Show comment
Hide comment
@redware

redware Apr 20, 2013

@aerlijman - thank you. This worked with signalr-1.0.0-rc2 and an ipod touch running IOS 6.0.1. I can see now where there is some documentation on SignalR at http://msdn.microsoft.com/en-us/library/jj943737(v=vs.100).aspx which I did not see before. Thank you for chasing this down... I am going to test a Windows Server 2012 sometime soon so see what happens with websockets on the iphone.

redware commented Apr 20, 2013

@aerlijman - thank you. This worked with signalr-1.0.0-rc2 and an ipod touch running IOS 6.0.1. I can see now where there is some documentation on SignalR at http://msdn.microsoft.com/en-us/library/jj943737(v=vs.100).aspx which I did not see before. Thank you for chasing this down... I am going to test a Windows Server 2012 sometime soon so see what happens with websockets on the iphone.

@gustavo-armenta

This comment has been minimized.

Show comment
Hide comment
@gustavo-armenta

gustavo-armenta May 9, 2013

Contributor

@aerlijman @Jazaret
I tried to repro this problem without success. I am downloading 2 images of 25MB each. The behavior I see in iPhone 5 Safari is that first it downloads all the images, and then SignalR connection is started. I tried both Wi-FI and 4G forcing longPolling transport.

Please share a standalone repro. If you can't, then you can help analyzing the problem.

  1. On your HTML body page add
<ul id="Messages"></ul>
  1. On jquery.signalr-XXX.js, find the log method (around line 50) and add the second line below so SignalR logging is printed in the screen.
m = "[" + new Date().toTimeString() + "] SignalR: " + msg;
$("#Messages").append("<li>[console] " + m + "</li>");
  1. Then, once you see it got stucked somewhere, you can find it in the javascript and add more logging lines to troubleshoot like:
connection.log("executing this?");

I would prefer a repro, but I am trying to give you options.

Contributor

gustavo-armenta commented May 9, 2013

@aerlijman @Jazaret
I tried to repro this problem without success. I am downloading 2 images of 25MB each. The behavior I see in iPhone 5 Safari is that first it downloads all the images, and then SignalR connection is started. I tried both Wi-FI and 4G forcing longPolling transport.

Please share a standalone repro. If you can't, then you can help analyzing the problem.

  1. On your HTML body page add
<ul id="Messages"></ul>
  1. On jquery.signalr-XXX.js, find the log method (around line 50) and add the second line below so SignalR logging is printed in the screen.
m = "[" + new Date().toTimeString() + "] SignalR: " + msg;
$("#Messages").append("<li>[console] " + m + "</li>");
  1. Then, once you see it got stucked somewhere, you can find it in the javascript and add more logging lines to troubleshoot like:
connection.log("executing this?");

I would prefer a repro, but I am trying to give you options.

@elgerm

This comment has been minimized.

Show comment
Hide comment
@elgerm

elgerm May 13, 2013

@gustavo-armenta Try loading dynamic content after signalr is loaded. Like popping up an iframe (jqueryui dialog for example), or do various ajax requests. It's painfully slow or they don't work at all on IOS safari with signalr loaded with any transport I tested. With longpolling it seems that the content that doesnt' finish loading, finishes when a new connection is started (by default every minute).

elgerm commented May 13, 2013

@gustavo-armenta Try loading dynamic content after signalr is loaded. Like popping up an iframe (jqueryui dialog for example), or do various ajax requests. It's painfully slow or they don't work at all on IOS safari with signalr loaded with any transport I tested. With longpolling it seems that the content that doesnt' finish loading, finishes when a new connection is started (by default every minute).

@aerlijman

This comment has been minimized.

Show comment
Hide comment
@aerlijman

aerlijman May 15, 2013

@gustavo-armenta what I do is to start signalR in a jquery mobile app and in the pageshow event request some json using ajax. When I get it, I put it in a listview. That json must have images and text. There you will see that images are not displayed - downloaded because SignalR is taking the connection. With longpolling and my schema described above, SignalR has time to live.

aerlijman commented May 15, 2013

@gustavo-armenta what I do is to start signalR in a jquery mobile app and in the pageshow event request some json using ajax. When I get it, I put it in a listview. That json must have images and text. There you will see that images are not displayed - downloaded because SignalR is taking the connection. With longpolling and my schema described above, SignalR has time to live.

@elgerm

This comment has been minimized.

Show comment
Hide comment
@elgerm

elgerm May 15, 2013

@aerlijman Please don't take this in a bad way, but your solution defies the reason why one should use signalr. I can just set up (or in my case continue) a simple home made polling technique which would be a lot easier to implement than signalr. Signalr is about push technology not pull.

Also, the 'LongPollDelay' property you set to 5 milliseconds (or the msdn docs are incorrect)

elgerm commented May 15, 2013

@aerlijman Please don't take this in a bad way, but your solution defies the reason why one should use signalr. I can just set up (or in my case continue) a simple home made polling technique which would be a lot easier to implement than signalr. Signalr is about push technology not pull.

Also, the 'LongPollDelay' property you set to 5 milliseconds (or the msdn docs are incorrect)

@aerlijman

This comment has been minimized.

Show comment
Hide comment
@aerlijman

aerlijman May 15, 2013

@gustavo-armenta I totally agree with you. The thing is that my app involves browsers and mobile clients chatting... and I think that SignalR solves all the issues. The only problem is with iOS due to the change they made in version 6.0.
The LongPollDelay is working with my code. Can you send me the MSDN reference to check?
Thx

aerlijman commented May 15, 2013

@gustavo-armenta I totally agree with you. The thing is that my app involves browsers and mobile clients chatting... and I think that SignalR solves all the issues. The only problem is with iOS due to the change they made in version 6.0.
The LongPollDelay is working with my code. Can you send me the MSDN reference to check?
Thx

@aerlijman

This comment has been minimized.

Show comment
Hide comment
@aerlijman

aerlijman May 15, 2013

@gustavo-armenta 5000 milliseconds and 1 seconds are the values you need to connect for 1 sec, and wait 5 secs before polling again. My values are right and working.

aerlijman commented May 15, 2013

@gustavo-armenta 5000 milliseconds and 1 seconds are the values you need to connect for 1 sec, and wait 5 secs before polling again. My values are right and working.

@elgerm

This comment has been minimized.

Show comment
Hide comment
@elgerm

elgerm May 15, 2013

You mean you changed 5ms to 5000ms and edited your answers.

by the way: i'm not gustavo-armenta.

I hope the signalr team will fix this bug. Now signalr and mobile safari is broken.

elgerm commented May 15, 2013

You mean you changed 5ms to 5000ms and edited your answers.

by the way: i'm not gustavo-armenta.

I hope the signalr team will fix this bug. Now signalr and mobile safari is broken.

@aerlijman

This comment has been minimized.

Show comment
Hide comment
@aerlijman

aerlijman May 15, 2013

@elgerm :)
I have never changed or edited the 5000ms. They were always there in my post. No idea where you got those 5.

aerlijman commented May 15, 2013

@elgerm :)
I have never changed or edited the 5000ms. They were always there in my post. No idea where you got those 5.

@elgerm

This comment has been minimized.

Show comment
Hide comment
@elgerm

elgerm May 15, 2013

Oh well, lets just focus on the problem here then.

elgerm commented May 15, 2013

Oh well, lets just focus on the problem here then.

@davidfowl

This comment has been minimized.

Show comment
Hide comment
@davidfowl

davidfowl May 15, 2013

Member

Sorry to say but if there is a single connection limit per domain the only options are to maybe allow for some kind of short polling like @aerlijman has configured. Either that or you need to serve images from another domain. This issue can be reproduced without SignalR and even though we try to do things to hide complexities of each browser/device, sometimes the platform just has limitations and you have to work around them.

In the mean time if anybody else has any ideas, we're all ears.

Some background:

https://news.ycombinator.com/item?id=4552072

SSE without SignalR:

#215 (comment)

Member

davidfowl commented May 15, 2013

Sorry to say but if there is a single connection limit per domain the only options are to maybe allow for some kind of short polling like @aerlijman has configured. Either that or you need to serve images from another domain. This issue can be reproduced without SignalR and even though we try to do things to hide complexities of each browser/device, sometimes the platform just has limitations and you have to work around them.

In the mean time if anybody else has any ideas, we're all ears.

Some background:

https://news.ycombinator.com/item?id=4552072

SSE without SignalR:

#215 (comment)

@DamianEdwards

This comment has been minimized.

Show comment
Hide comment
@DamianEdwards

DamianEdwards May 28, 2013

Member

@gustavo-armenta can you please confirm exactly which transports and conditions cause this issue and the workarounds, e.g.:

  • Is websockets OK?
  • Does SSE and long polling always exhibit the issue on all iOS versions of just specific versions?
  • Does serving images from a sub-domain of the SignalR connection domain solve the issue?
Member

DamianEdwards commented May 28, 2013

@gustavo-armenta can you please confirm exactly which transports and conditions cause this issue and the workarounds, e.g.:

  • Is websockets OK?
  • Does SSE and long polling always exhibit the issue on all iOS versions of just specific versions?
  • Does serving images from a sub-domain of the SignalR connection domain solve the issue?
@Legioth

This comment has been minimized.

Show comment
Hide comment
@Legioth

Legioth May 30, 2013

Found this issue when googling for a similar problem that we observed in an unrelated piece of software. Just thought that you might be interested in the solution that we eventually found: It seems that the problem is related to HTTP keepalive - adding a "Connection: close" header to the long polling response seems to fix the problem.

Edit: The Connection header should of course be on the response and not on the request as I originally wrote.

Legioth commented May 30, 2013

Found this issue when googling for a similar problem that we observed in an unrelated piece of software. Just thought that you might be interested in the solution that we eventually found: It seems that the problem is related to HTTP keepalive - adding a "Connection: close" header to the long polling response seems to fix the problem.

Edit: The Connection header should of course be on the response and not on the request as I originally wrote.

@aerlijman

This comment has been minimized.

Show comment
Hide comment
@aerlijman

aerlijman May 30, 2013

@Legioth Can you include a sample code?

aerlijman commented May 30, 2013

@Legioth Can you include a sample code?

@Legioth

This comment has been minimized.

Show comment
Hide comment
@Legioth

Legioth May 30, 2013

@aerlijman I don't think I have any relevant sample code to show considering that I'm working with a Java-based framework and have never even used SignalR - I just happened to discover that you are seeing the same problem and that a similar workaround would most likely be appropriate.

Legioth commented May 30, 2013

@aerlijman I don't think I have any relevant sample code to show considering that I'm working with a Java-based framework and have never even used SignalR - I just happened to discover that you are seeing the same problem and that a similar workaround would most likely be appropriate.

@aerlijman

This comment has been minimized.

Show comment
Hide comment
@aerlijman

aerlijman May 30, 2013

@Legioth So you mean that SignalR team should change the low level code, right? not the end user, as far as I could understand.

aerlijman commented May 30, 2013

@Legioth So you mean that SignalR team should change the low level code, right? not the end user, as far as I could understand.

@davidfowl

This comment has been minimized.

Show comment
Hide comment
@davidfowl

davidfowl May 30, 2013

Member

@Legioth are you saying that disabling HTTP keep alive makes longpolling work without any of these tricks on iOS?

Member

davidfowl commented May 30, 2013

@Legioth are you saying that disabling HTTP keep alive makes longpolling work without any of these tricks on iOS?

@Legioth

This comment has been minimized.

Show comment
Hide comment
@Legioth

Legioth May 30, 2013

@aerlijman Can't really say where the fix should be applied as I'm not familiar with how SignalR is designed. I would however assume that a low level fix would be most appropriate. There might also be some way for developers using SignalR to apply a workaround until a fixed version is available, but I can't tell. There might also be some way of configuring the HTTP server to disable keepalive for all requests or requests to some specific path, but it's once a gain something that I don't have any knowledge about because I'm not a .NET developer.

@davidfowl That's how it worked out in the case we had with very similar symptoms. There might of course also be some other differences between how SignalR and the framework I'm using handles long polling that means that just disabling keepalive is not enough in your case.

Legioth commented May 30, 2013

@aerlijman Can't really say where the fix should be applied as I'm not familiar with how SignalR is designed. I would however assume that a low level fix would be most appropriate. There might also be some way for developers using SignalR to apply a workaround until a fixed version is available, but I can't tell. There might also be some way of configuring the HTTP server to disable keepalive for all requests or requests to some specific path, but it's once a gain something that I don't have any knowledge about because I'm not a .NET developer.

@davidfowl That's how it worked out in the case we had with very similar symptoms. There might of course also be some other differences between how SignalR and the framework I'm using handles long polling that means that just disabling keepalive is not enough in your case.

@aerlijman

This comment has been minimized.

Show comment
Hide comment
@aerlijman

aerlijman May 30, 2013

@davidfowl If you can give me some code example where I can do what @Legioth says, I can test it with app and see what happens.

aerlijman commented May 30, 2013

@davidfowl If you can give me some code example where I can do what @Legioth says, I can test it with app and see what happens.

@davidfowl

This comment has been minimized.

Show comment
Hide comment
@davidfowl

davidfowl May 30, 2013

Member

I'm not sure if this is possible with code but here's the IIS7 way:

http://msmvps.com/blogs/bernard/archive/2007/07/10/how-to-configure-http-keep-alive-in-iis-7.aspx

Member

davidfowl commented May 30, 2013

I'm not sure if this is possible with code but here's the IIS7 way:

http://msmvps.com/blogs/bernard/archive/2007/07/10/how-to-configure-http-keep-alive-in-iis-7.aspx

@aerlijman

This comment has been minimized.

Show comment
Hide comment
@aerlijman

aerlijman May 30, 2013

@davidfowl Thx, I will try that in the next days and see what happens.

aerlijman commented May 30, 2013

@davidfowl Thx, I will try that in the next days and see what happens.

@gustavo-armenta

This comment has been minimized.

Show comment
Hide comment
@gustavo-armenta

gustavo-armenta May 30, 2013

Contributor

@DamianEdwards

Is websockets OK? No, websockets can also fail although less common
Does SSE and long polling always exhibit the issue on all iOS versions of just specific versions? Yes, up to current version which is iOS 6.1.3
Does serving images from a sub-domain of the SignalR connection domain solve the issue? No, loading images from another server did not help. Once images are cached on client, everything works fine

Contributor

gustavo-armenta commented May 30, 2013

@DamianEdwards

Is websockets OK? No, websockets can also fail although less common
Does SSE and long polling always exhibit the issue on all iOS versions of just specific versions? Yes, up to current version which is iOS 6.1.3
Does serving images from a sub-domain of the SignalR connection domain solve the issue? No, loading images from another server did not help. Once images are cached on client, everything works fine

@aerlijman

This comment has been minimized.

Show comment
Hide comment
@aerlijman

aerlijman May 30, 2013

@davidfowl and @Legioth I did some tests with the keep alive disabled in the IIS but got the same result. Images are not displayed in the same conditions described above. I would like someone else to try it anyway just to confirm.

aerlijman commented May 30, 2013

@davidfowl and @Legioth I did some tests with the keep alive disabled in the IIS but got the same result. Images are not displayed in the same conditions described above. I would like someone else to try it anyway just to confirm.

@ksolberg

This comment has been minimized.

Show comment
Hide comment
@ksolberg

ksolberg Jun 4, 2013

@davidfowl @aerlijman @Legioth Images actually do load now after turning Keep Alive off in IIS! (Windows 8/IIS 8).

ksolberg commented Jun 4, 2013

@davidfowl @aerlijman @Legioth Images actually do load now after turning Keep Alive off in IIS! (Windows 8/IIS 8).

@DamianEdwards

This comment has been minimized.

Show comment
Hide comment
@DamianEdwards

DamianEdwards Jun 7, 2013

Member

That's great news.That gives us something to investigate further and others a workaround in the meantime.

Member

DamianEdwards commented Jun 7, 2013

That's great news.That gives us something to investigate further and others a workaround in the meantime.

@redware

This comment has been minimized.

Show comment
Hide comment
@redware

redware Jun 9, 2013

I think you may have moved on but I can confirm that our original problem of the combination of jquery and IOS and signalr preventing images from displaying is solved with the long polling delay suggested by @aerlijman:

    GlobalHost.Configuration.ConnectionTimeout = TimeSpan.FromSeconds(1);
    Microsoft.AspNet.SignalR.Transports.LongPollingTransport.LongPollDelay = 5000;
    RouteTable.Routes.MapHubs();

I am using Microsoft Azure to host the site and unfortunately that is Windows 2008 server so only long polling is supported and I have not done anything to the keepalive setting. I understood that the keepalive is quite serious for networking performance so is it better to use the long polling delay rather than turn off keepalive ?

You must enable the HTTP keep-alive response header when you use integrated security or connection-based authentication services, such as Integrated Windows authentication.

Another aspect when using Apple iphones is that the network traffic icon is displaying every 5 seconds making me wonder how much bandwidth is required for the singlar polling and whether this might be costly in terms of mobile data ?

redware commented Jun 9, 2013

I think you may have moved on but I can confirm that our original problem of the combination of jquery and IOS and signalr preventing images from displaying is solved with the long polling delay suggested by @aerlijman:

    GlobalHost.Configuration.ConnectionTimeout = TimeSpan.FromSeconds(1);
    Microsoft.AspNet.SignalR.Transports.LongPollingTransport.LongPollDelay = 5000;
    RouteTable.Routes.MapHubs();

I am using Microsoft Azure to host the site and unfortunately that is Windows 2008 server so only long polling is supported and I have not done anything to the keepalive setting. I understood that the keepalive is quite serious for networking performance so is it better to use the long polling delay rather than turn off keepalive ?

You must enable the HTTP keep-alive response header when you use integrated security or connection-based authentication services, such as Integrated Windows authentication.

Another aspect when using Apple iphones is that the network traffic icon is displaying every 5 seconds making me wonder how much bandwidth is required for the singlar polling and whether this might be costly in terms of mobile data ?

@robatwilliams

This comment has been minimized.

Show comment
Hide comment
@robatwilliams

robatwilliams Jun 18, 2013

This issue seems to be related to a possible bug in Safari mobile that I encountered when loading script files via requirejs while a signalR connection is connected.

The actual issue can be reproduced without requirejs or signalR, and my hunch is that it's due to the way that Safari mobile queues up resources for loading on its available connections (of which it has max 5 per host).

It seems that it determines up front which connection will be used to load a resource, and will not revise this later. So if it sees 10 script tags (with async attribute set), it will load the 1st and the 6th on its first connection, 2nd and 7th on its second connection, and so on. If for example the 1st script takes a long time to load, then it will wait until that has finished loading before loading the 6th script, so that it can load it on its first connection - rather than using one of its other connections as they become available.

This is on an iPad 2 running iOS 6.0, User Agent: Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A403 Safari/8536.25. I can make the test page and script files I used available if anyone would find them helpful.

In my signalR and requirejs scenario, we are using SSE transport which means that connection 1 will never become available. With fairly equal sized scripts, scripts 1-4 and 6-9 will load correctly (presumably using connections 2-5), but scripts 5 and 10 will never load, presumably because Safari is waiting for connection 1 to become available to load them on. Presumably the same pattern would happen with more scripts, with each 5th one failing.

This "every 5th fails" is consistently reproducible on a slow connection (simulated using Fiddler), but even on a fast connection, the 5th script always fails.

I'm guessing that it's the same thing or similar that would be causing the images not loading issue - that Safari is for some reason waiting to load them using the connection that is in forever in use by signalR.

robatwilliams commented Jun 18, 2013

This issue seems to be related to a possible bug in Safari mobile that I encountered when loading script files via requirejs while a signalR connection is connected.

The actual issue can be reproduced without requirejs or signalR, and my hunch is that it's due to the way that Safari mobile queues up resources for loading on its available connections (of which it has max 5 per host).

It seems that it determines up front which connection will be used to load a resource, and will not revise this later. So if it sees 10 script tags (with async attribute set), it will load the 1st and the 6th on its first connection, 2nd and 7th on its second connection, and so on. If for example the 1st script takes a long time to load, then it will wait until that has finished loading before loading the 6th script, so that it can load it on its first connection - rather than using one of its other connections as they become available.

This is on an iPad 2 running iOS 6.0, User Agent: Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A403 Safari/8536.25. I can make the test page and script files I used available if anyone would find them helpful.

In my signalR and requirejs scenario, we are using SSE transport which means that connection 1 will never become available. With fairly equal sized scripts, scripts 1-4 and 6-9 will load correctly (presumably using connections 2-5), but scripts 5 and 10 will never load, presumably because Safari is waiting for connection 1 to become available to load them on. Presumably the same pattern would happen with more scripts, with each 5th one failing.

This "every 5th fails" is consistently reproducible on a slow connection (simulated using Fiddler), but even on a fast connection, the 5th script always fails.

I'm guessing that it's the same thing or similar that would be causing the images not loading issue - that Safari is for some reason waiting to load them using the connection that is in forever in use by signalR.

@KodeKreachor

This comment has been minimized.

Show comment
Hide comment
@KodeKreachor

KodeKreachor Jun 26, 2013

@davidfowl @aerlijman @Legioth As an alternative to requesting images from an entirely separate domain, will requesting images from a subdomain of my site's primary domain work as well?

KodeKreachor commented Jun 26, 2013

@davidfowl @aerlijman @Legioth As an alternative to requesting images from an entirely separate domain, will requesting images from a subdomain of my site's primary domain work as well?

@gustavo-armenta

This comment has been minimized.

Show comment
Hide comment
@gustavo-armenta

gustavo-armenta Jun 26, 2013

Contributor

@KodeKreachor.
It will not help to host the images on another domain or sub-domain. @ksolberg mentioned disabling Http Keep Alive on IIS solved the issue. Could you try it? Open IIS Manager, select your virtual directory, on Features View select Http Response Headers, select Set Common Headers, uncheck "Enable HTTP Keep-alive"

Contributor

gustavo-armenta commented Jun 26, 2013

@KodeKreachor.
It will not help to host the images on another domain or sub-domain. @ksolberg mentioned disabling Http Keep Alive on IIS solved the issue. Could you try it? Open IIS Manager, select your virtual directory, on Features View select Http Response Headers, select Set Common Headers, uncheck "Enable HTTP Keep-alive"

@KodeKreachor

This comment has been minimized.

Show comment
Hide comment
@KodeKreachor

KodeKreachor Jun 28, 2013

@gustavo-armenta Thanks for the reply. Based on research it makes sense that disabling Http Keep Alive in IIS would work, but I don't think I'm willing to sacrifice the overall performance of my site and punish all users on all devices just because Apple wrote a buggy browser. I'll probably just check the user agent and force iPads to poll

KodeKreachor commented Jun 28, 2013

@gustavo-armenta Thanks for the reply. Based on research it makes sense that disabling Http Keep Alive in IIS would work, but I don't think I'm willing to sacrifice the overall performance of my site and punish all users on all devices just because Apple wrote a buggy browser. I'll probably just check the user agent and force iPads to poll

@davidfowl

This comment has been minimized.

Show comment
Hide comment
@davidfowl

davidfowl Jul 4, 2013

Member

Seems after evaluating all options we'd need to do one of the following:

  • Implement regular polling (extension of the longpolling transport).
  • Turn Http keep alive off for SignalR longpolling requests when on iOS.
Member

davidfowl commented Jul 4, 2013

Seems after evaluating all options we'd need to do one of the following:

  • Implement regular polling (extension of the longpolling transport).
  • Turn Http keep alive off for SignalR longpolling requests when on iOS.
@aerlijman

This comment has been minimized.

Show comment
Hide comment
@aerlijman

aerlijman Jul 4, 2013

@gustavo-armenta I agree with @KodeKreachor . I have no real knowledge about disabling the keep alive thing.
So I guess there is not much to discuss here and we can leave this open for others with this problem to decide and discuss.
Thx all!

aerlijman commented Jul 4, 2013

@gustavo-armenta I agree with @KodeKreachor . I have no real knowledge about disabling the keep alive thing.
So I guess there is not much to discuss here and we can leave this open for others with this problem to decide and discuss.
Thx all!

@Mike-EEE

This comment has been minimized.

Show comment
Hide comment
@Mike-EEE

Mike-EEE Sep 17, 2013

I am also running into problems with using SignalR in a requirejs solution when running on Safari. In my case, the page will load, but it will take around 2 minutes for a call to the server to return. The application works after that, but it would be nice to get some guidance for a possible work-around this issue (I've tried the suggestions in this thread to no avail).

Mike-EEE commented Sep 17, 2013

I am also running into problems with using SignalR in a requirejs solution when running on Safari. In my case, the page will load, but it will take around 2 minutes for a call to the server to return. The application works after that, but it would be nice to get some guidance for a possible work-around this issue (I've tried the suggestions in this thread to no avail).

@elgerm

This comment has been minimized.

Show comment
Hide comment
@elgerm

elgerm Sep 17, 2013

Turning off keep alive is no option, as it will be a terrible user
experience. Anything (images/ajax calls) will not load correctly if you
have a signalr connection (or any persistent connection) in IOS safari. If
you do any ajax loading after the signalr connection is established, 1 out
of 5 will hang until signalr reconnects.

The only solution is a polling mode variant. I wish the signalr team could
see that signalr is just broken with IOS safari.

On Tue, Sep 17, 2013 at 8:52 PM, MichaelD! notifications@github.com wrote:

I am also running into problems with using SignalR in a requirejs solution
when running on Safari. In my case, the page will load, but it will take 2
or 3 minutes for a call to the server to return. The application works
after that, but it would be nice to get some guidance for a possible
work-around this issue (I've tried the suggestions in this thread to no
avail).


Reply to this email directly or view it on GitHubhttps://github.com/SignalR/SignalR/issues/1406#issuecomment-24589350
.

elgerm commented Sep 17, 2013

Turning off keep alive is no option, as it will be a terrible user
experience. Anything (images/ajax calls) will not load correctly if you
have a signalr connection (or any persistent connection) in IOS safari. If
you do any ajax loading after the signalr connection is established, 1 out
of 5 will hang until signalr reconnects.

The only solution is a polling mode variant. I wish the signalr team could
see that signalr is just broken with IOS safari.

On Tue, Sep 17, 2013 at 8:52 PM, MichaelD! notifications@github.com wrote:

I am also running into problems with using SignalR in a requirejs solution
when running on Safari. In my case, the page will load, but it will take 2
or 3 minutes for a call to the server to return. The application works
after that, but it would be nice to get some guidance for a possible
work-around this issue (I've tried the suggestions in this thread to no
avail).


Reply to this email directly or view it on GitHubhttps://github.com/SignalR/SignalR/issues/1406#issuecomment-24589350
.

@Mike-EEE

This comment has been minimized.

Show comment
Hide comment
@Mike-EEE

Mike-EEE Sep 17, 2013

Hmmm... turning off Http Alive in IIS didn't work for me, and in fact broke my other environments (Windows & Droid). I am also experiencing the 1:50 delay in the first call in Safari. This is also the same setting as the GlobalHost.Configuration.ConnectionTimeout, but modifying this setting does not shorten the delay time (it remains at 1:50 regardless of what I set GlobalHost.Configuration.ConnectionTimeout to).

I should also note that I am running Safari in Windows, as I do not have an iOS device. I figured once I get it working in Windows I'll bring in a couple friends who do have iPads to test...

Mike-EEE commented Sep 17, 2013

Hmmm... turning off Http Alive in IIS didn't work for me, and in fact broke my other environments (Windows & Droid). I am also experiencing the 1:50 delay in the first call in Safari. This is also the same setting as the GlobalHost.Configuration.ConnectionTimeout, but modifying this setting does not shorten the delay time (it remains at 1:50 regardless of what I set GlobalHost.Configuration.ConnectionTimeout to).

I should also note that I am running Safari in Windows, as I do not have an iOS device. I figured once I get it working in Windows I'll bring in a couple friends who do have iPads to test...

@davidfowl

This comment has been minimized.

Show comment
Hide comment
@davidfowl

davidfowl Sep 17, 2013

Member

To the people having the 1:50 delay, what version of SignalR are you using and what kind of application is it (MVC)? If you're using 2.x, that's a different problem entirely.

Member

davidfowl commented Sep 17, 2013

To the people having the 1:50 delay, what version of SignalR are you using and what kind of application is it (MVC)? If you're using 2.x, that's a different problem entirely.

@Mike-EEE

This comment has been minimized.

Show comment
Hide comment
@Mike-EEE

Mike-EEE Sep 17, 2013

I am using SignalR version 2.0.0-rc1, on an ASP.NET MVC4 application.

Mike-EEE commented Sep 17, 2013

I am using SignalR version 2.0.0-rc1, on an ASP.NET MVC4 application.

@davidfowl

This comment has been minimized.

Show comment
Hide comment
@davidfowl

davidfowl Sep 17, 2013

Member

That hang has nothing to do with iOS and the bug was fixed in 2.0.0 final which isn't out as yet. You can read about it here #2306

Member

davidfowl commented Sep 17, 2013

That hang has nothing to do with iOS and the bug was fixed in 2.0.0 final which isn't out as yet. You can read about it here #2306

@Mike-EEE

This comment has been minimized.

Show comment
Hide comment
@Mike-EEE

Mike-EEE Sep 17, 2013

Great. Thanks for the clarification, @davidfowl.

Mike-EEE commented Sep 17, 2013

Great. Thanks for the clarification, @davidfowl.

@adaptive-bkinchin

This comment has been minimized.

Show comment
Hide comment
@adaptive-bkinchin

adaptive-bkinchin Mar 28, 2014

We have been impacted by this issue. We are using iPad4 (iOS 7.1), and have found several of our images were not loading using Safari. Our web page uses signalr and a heavy use of ExtJS and Ajaxy behaviour. The images that aren't displaying are those that attempt to load sometime after the initial page load (and after signalr is up and running). The voiced options of disabling signalr (temporarily or permanently) or using subdomains for signalr were not feasible for us. Given that this website can only be accessed by our customers (and we can use this workaround), we tested a workaround of installing Chrome on the iPad. Chrome on iPad is currently working well for us, with signalr and images working seamlessly. We did not have issues with SurfacePro or an Android based tablet.

adaptive-bkinchin commented Mar 28, 2014

We have been impacted by this issue. We are using iPad4 (iOS 7.1), and have found several of our images were not loading using Safari. Our web page uses signalr and a heavy use of ExtJS and Ajaxy behaviour. The images that aren't displaying are those that attempt to load sometime after the initial page load (and after signalr is up and running). The voiced options of disabling signalr (temporarily or permanently) or using subdomains for signalr were not feasible for us. Given that this website can only be accessed by our customers (and we can use this workaround), we tested a workaround of installing Chrome on the iPad. Chrome on iPad is currently working well for us, with signalr and images working seamlessly. We did not have issues with SurfacePro or an Android based tablet.

@DamianEdwards

This comment has been minimized.

Show comment
Hide comment
@DamianEdwards

DamianEdwards Apr 14, 2014

Member

Given this is an issue caused by how iOS queues requests that is outside of our control I'm closing this bug. There are workarounds detailed above.

Member

DamianEdwards commented Apr 14, 2014

Given this is an issue caused by how iOS queues requests that is outside of our control I'm closing this bug. There are workarounds detailed above.

@JoergTiedemann

This comment has been minimized.

Show comment
Hide comment
@JoergTiedemann

JoergTiedemann Apr 14, 2014

The problem is not a bug in safari, the problem is that safari only allowed one connection to the server and chrome allows more. So if the page is loaded and signalr is started the only available connection is used so safari cannot load the requested images via ajax from the sever. The only right solution is to put the signalr or long polling queries in a webworker, then it will work with safari. But the problem is that signalr uses jquery so it's not possible to use signalr in a webworker. I think a good solution good be to remove jquery from signalr but this issue was moved from the milestone list.
So at this point only tricks discribed above can help, but I think that's not what the users want. Apple will definitly not solve the problem at safari to allow more the one connection as for performance reasons

JoergTiedemann commented Apr 14, 2014

The problem is not a bug in safari, the problem is that safari only allowed one connection to the server and chrome allows more. So if the page is loaded and signalr is started the only available connection is used so safari cannot load the requested images via ajax from the sever. The only right solution is to put the signalr or long polling queries in a webworker, then it will work with safari. But the problem is that signalr uses jquery so it's not possible to use signalr in a webworker. I think a good solution good be to remove jquery from signalr but this issue was moved from the milestone list.
So at this point only tricks discribed above can help, but I think that's not what the users want. Apple will definitly not solve the problem at safari to allow more the one connection as for performance reasons

@DamianEdwards

This comment has been minimized.

Show comment
Hide comment
@DamianEdwards

DamianEdwards Apr 14, 2014

Member

Agreed, we never claimed it was a bug with Safari, but rather a side-effect of how they queue HTTP requests (that apparently only they do in this way). That behavior is beyond our control so workarounds are the only recourse for now. Once we finish the JS client re-write to remove dependencies on jQuery and anything else not available in web worker context, running in a web worker would indeed be a suitable solution.

Member

DamianEdwards commented Apr 14, 2014

Agreed, we never claimed it was a bug with Safari, but rather a side-effect of how they queue HTTP requests (that apparently only they do in this way). That behavior is beyond our control so workarounds are the only recourse for now. Once we finish the JS client re-write to remove dependencies on jQuery and anything else not available in web worker context, running in a web worker would indeed be a suitable solution.

@JoergTiedemann

This comment has been minimized.

Show comment
Hide comment
@JoergTiedemann

JoergTiedemann Apr 15, 2014

Yes but at which time is the re-write of the JS client finished ?
Was actual worked on that issue ? Or is the issue on the big list with no realistic date in the future ?

JoergTiedemann commented Apr 15, 2014

Yes but at which time is the re-write of the JS client finished ?
Was actual worked on that issue ? Or is the issue on the big list with no realistic date in the future ?

@DamianEdwards

This comment has been minimized.

Show comment
Hide comment
@DamianEdwards

DamianEdwards Apr 15, 2014

Member

@JoergTiedemann we plan to do it this year, sorry can't be more specific than that

Member

DamianEdwards commented Apr 15, 2014

@JoergTiedemann we plan to do it this year, sorry can't be more specific than that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment