Windows Phone Long Poll, 60 seconds TimeOut


Hello
The Windows Phone application needs to connect to the server and receive messages from it. This is done using WCF and a long poll on the server. 3 minutes is a timeout defined on the server. A call from the phone window is made using the HttpWebRequest.
The problem is that Windows Phone devices have a timeout of 60 seconds to receive a request (the emulator has a different value, more than 3 minutes).
Currently, I cannot reduce the server timeout. Running a new GetRequest after 60 seconds no longer receives messages.
Does anyone have an idea?
Thanks

+4
source share
1 answer

I don’t think leaving an open connection is a good idea on mobile devices. I guess what you do. In my application, I would just poll when necessary, creating a new HttpWebRequest. But it made sense to do this in my application, because I update the train's arrival status every 40 seconds.

If you are trying to retrieve data according to a given schedule, turn on the timer and simply call the web server every 3 minutes or whatever it requires.

If you want to be able to check things (when the application is closed) or if fresh data rarely appears on the server, you need to implement the Push mechanism.

Update: Here is a good article about the timeout problem - http://blog.xyzzer.me/2011/03/10/real-time-client-server-communication-on-windows-phone-with-long-polling/

Update 2: What to do if you stack it so that you have cascading connections. I mean, since you cannot switch to a connection in 60 seconds, you can write a class that will make two connections, and as soon as one of them starts a timeout, say a few seconds ago, you can start opening another connection - You can choose the time so that between them there is no more than 5 seconds. That way you can have an always open connection.

Also look what these guys did using the GChat application, they have the source code on this link . This may provide a more correct design.

+3
source

Source: https://habr.com/ru/post/1403540/


All Articles