Websockets service crashes after unexpected closing connections - asp.net-mvc

I have an Asp.Net MVC backend and a mobile application (cordova).
I added a websockets service to backend using this library as starting point.
Websockets service crashes if client disconnects very often without normal closing connection (just close application). Usually three times enough for reproducing.
I added try-catch block to this function and it works fine for one unexpectedly closed connection.
After reproducing service responses "503 Service Unavailable" some times, after that works fine.
I added try-catch to all functions and use ILooger object in catch block for logging but I don't see errors in logs and on Azure portal.
Any ideas?

I moved a websockets code to a separate app service and it works fine. I use sevice bus for communication between a general service and the websockets service.

Related

Gsm800L gprs disconnect issue

I need to decide which gsm800l module to use for my application. My application is to communicate to a server continuously by sending and receiving a string but needs to run continuously.
As of now I’m using the sim800l module, it works fine and connects to the server but after a couple of minutes it disconnects and probably never connects again I need to manually reset.
How can I resolve this issue?

Socket.io client fails to reconnect to server after an abrupt disconnection

I am using the socket.io NodeJs server library and the Swift client library. Majority of the time the client successfully reconnects to the server after a disconnection, however intermittently we are seeing abrupt disconnections and then the client is never able to reconnect.
In the server logs, I see the client sending a connection attempt at the defined re-try interval, however it just never successfully establishes the connection and then we get a ping timeout.
There is surprisingly very little support for Socket.io which makes this extremely difficult to solve.
I figured out a solution to our problem by forcing a new engine to be created in the client upon reconnections. When creating the SocketIOClient object, set the forceNew variable to true which allows the client to create a new engine and thus always successfully establishes the connection.
return SocketIOClient(socketURL: socketURL, config: [.forceNew(true)])

Communication between asp.net app and a serviceworker, via signalR?

I'm new to serviceworkers and I wonder how could I connect my serviceworker to my asp.net application. My js client already is communicated with a service worker and it's able to show notifications.
However, I've seen that some webs (e.g facebook) send notifications even the browser's tab ins't opened (not inactive, not opened). I use signalR to communicate my app with the server. Would it be possible to communicate the serviceworker with the server? It would require to add signalR code to the serviceworker if I'm not wrong, but I don't think it's possible. I've seen that google has another way of communication, Google Cloud Communication
I can't use that, so any ideas of how could I solve this problem?
To make use of offline notifications (i.e., your browser is open but your page isn't), the browser itself needs to know about a messaging service that it can respond to, and which would let it know to wake up your service worker and give it a notification. These services are hard-coded into the browser. In Chrome's case, the service is GCM. And I believe Firefox is rolling out something of its own. You cannot wake up your service worker yourself from your server without going through one of these messaging services.
Remember that generally your service worker is asleep. The browser only wakes it up in response to specific events, and, if your pages are closed, there is no way to trigger a service worker event from your server, unless the browser provides a messaging service such as GCM.

Sync TCP Client in multi-client application without lags

I have application, whitch connents to N devices trought the network.
The problem is:
TCP Client class isn't async, I'm send the command to device, I want get answer now.
So, 2 or more active clients makes my app frozen.
Any ideas how to do some, that's will not freeze my application if many devices is enabled at one time?
TCP Client class uses Synapse classes package.
Thanks!
To avoid application hang, use a separate thread for every TCP client connection.
The thread then will run independently, connect to the device, and do the communication.
Note that the thread must not access objects/data in the main application thread without proper synchronization.

How can I open a web socket with Sails.JS without using a browser?

I have been trying to open a websocket from iOS with an API developed in Sails.JS running on Heroku. But I am not sure where to point the web socket.
Attempting to connect directly to ws://my-domain.herokuapp.com fails with a 503 error every time.
What I have noticed, however, when opening my app in chrome, and monitor the console - I occasionally see this error in the console:
WebSocket connection to 'ws://my-domain.herokuapp.com/socket.io/1/websocket/2RNf_dS2sjcShe397tEQ' failed: Unexpected response code: 503
But almost immediately after, it connects. My question is: where is the socket path on that URL coming from? Is that something that Sails.JS issues upon an HTTP Connection, and is that something I should request in iOS? Or am I missing something else?
I would suggest taking a look at: https://github.com/balderdashy/sails-examples/tree/master/SampleAppiOS. Instead of using web sockets, it uses socket.io.

Resources