0
votes

I have a problem with SignalR jQuery client given the following scenario:

  • The server is hosted on Azure as a worker role
  • REST APIs are implemented with WebApi2
  • Push hubs are served with SignalR
  • There are 2 clients:
    • Android
    • Webapp based on angularjs which uses ui-router and SingnalR jQuery client in the main state of the application (this state dies when the webapp is closed)

Here is how i get the anomaly:

  • Android client calls a REST API that invokes the push hub on the server. The push hub sends a notification to the angular client
  • The angular client receives the notification and calls another api on the server that sends a GCM notification on the Android client. When the client receives 200 OK as response to the called REST API, it calls another API hosted on a server running in localhost (with CORS enabled)
  • At this point SignalR client disconnects from the server, without being able to reconnect to it in a stable manner: it keeps disconnecting and reconnecting
  • This anomaly occurs if the angular client stays alive for several minutes (say, hours)
  • Refreshing the page fixes the problem

Do you have ideas about how to fix this problem without refreshing the page?

Thanks in advance

1

1 Answers

1
votes

Try enabling the "Always On" feature for your web app, this can be done via the web app settings.

How Azure App Service works is that the site content is stored on a file server, and then the site is loaded by a web worker when it is active. If the app is idle it will be unloaded, causing the process to be killed and your SignalR client disconnect. Always on means that your web app is always loaded.

Documentation for configuring web apps is here: https://azure.microsoft.com/en-us/documentation/articles/web-sites-configure/