I am trying to implement real time notification for a web application I an currently working on.
The problem is the connection is getting closed just after few seconds.Can It be possible to keep connection ideal.If not please suggest me the alternative to implement this.
Related
This question is with regards to my project on federated learning using the pysyft library, but those with the knowledge of websockets can help too since pysyft uses websockets for the server and client interaction.
To start off, i have an issue regarding server and client interaction. I have created a dashboard to launch a pysyft server and a pysyft client which connects to the aforementioned server. However, i have a scenario where i want to have the client disconnect from the server from time to time (manual disconnection) so as to perform changes in model parameters.
My solution was to perform a close() on the pysyft websocketClientWorker which calls the shutdown() function on the websocket object. Doing which, i presume, will close the connection between the client and the server. After whatever changes to the model parameters have been done. I will recreate the pysyft websocketClientWorker object again and perform the model training all over again. However, i am faced with the issue of : websocket._exceptions.WebSocketConnectionClosedException: socket is already closed. This exception is being thrown (despite the successful connection to the server) during the iteration of the dataloader.
Perhaps there's a better way to go about this scenario, or am i missing certain fundamental understanding of websockets. Any help will be appreciated. Thank you :)
I managed to find the solution to my question after days of thorough inspection of the pysyft library. Turns out there is no issue with the Websocket connection and re-connection. Apparently, the superclass of websocketclient (baseworker) contains a worker registry which caches the websocketclient objects when the auto_add variable is set to True. This registry is indexed by the websocketclient ID and thus, recreation of the websocketclient object will not get replaced in the registry if the ID is the same. Therefore, this explains the 'socket is already closed' issue since it's referencing to the previous websocketclient connection that I have closed. The solution was to simply call the remove_worker_from_local_worker_registry() method on the websocketclient object before closing its connection.
I have tried following the code snippet provided in flutter.io cookbook(https://flutter.io/cookbook/networking/web-sockets/) to connect to websockets.
It was working well for the test server "echo.websocket.org" provided in the code but same is not getting connected when trying with custom websocket server written in Spring. I have tried with multiple websockets which are working in other projects, even sample test websocket is also not getting connected.
Please help to resolve the issue or suggest steps to take to achieve successful connectivity to websockets.
I really appreciate any help you can provide.
Can you help me to make clear one thing about WebSockets and Spring Security auth? I have an js client with websocket connection. When I load it for first time the user is unautharized and my spring server returns undefined in frame.headers['user-name'] after websocket connect. Is it correct to make websocket reconnect on client side when user performs login/logout operations in sence to make websocket messaging authorized? The one thing is that after every connect client make some subscriptions and it sounds not good to make connect/disconnect and make new subcriptions every time. I hope you will help me and my question is clear. Sorry for my English. Thank you in advance.
I am working on designing a large scale web application that will heavily use WebSockets to communicate data between the client browser and our servers. The question that I have is how we are going to push application updates on our servers without our clients knowing that this is being done. We want to have as mush as 100% up time as possible.
The problem is with the WebSockets becoming closed if there is an application update being done on it. Is there a way to hand off an existing connection to another application server?
I was considering to implement some client side script that would automatically re-connect to the server if it was closed prematurely. However I would like to know from you smart people what other ideas that I can consider.
Thanks!
I'm trying to develop an extension that detects every connection made by the browser to figure out the URLs being accessed. I know that this is possible via writing an HTTP/SOCKS proxy and configuring the browser to flow traffic via that. However, that's kind of overkill for the application that I'm trying to develop and it's best done as a Firefox Add-on if that's possible. Any clues/pointers would be highly appreciated.
Use nsIHttpActivityDistributor and there is many information about the http transaction and socket transport through observeActivity callback.
Read the official documentation https://developer.mozilla.org/en/Monitoring_HTTP_activity.