-
Notifications
You must be signed in to change notification settings - Fork 32
Reconnect/Reinitialize service #13
Comments
Wow, never knew it worked like that. There is a A longer explanation as to why it is not publicly exposed - this class takes care of automatic re-connection in case of an error. The disconnect call does not clean up the state, so, as soon as it connects after calling Another - quite unrelated - approach, do not use Angular's dependency mechanism (at least not conventionally). That will allow you to create a new instance of the Service after a user is authenticated which will be unrelated to the previous one. This is the approach I am taking in running test cases. However it will not retain any previous subscriptions which will need to be subscribed afresh. This library is designed to allow multiple instances of the service, so, if it makes a cleaner design, you can have two injected instances, one for anonymous access and another for authenticated access. Let me know if any of the above will work for you. |
Thanks for response, I tried second approach. Created new Injectable provider that can instantiate new service and I access it through this provider. It works nicely and design is quite clean. If I run into situation where I'll need to keep my observers linked I'll probably try 1st approach too. Thanks a lot for help. |
Glad it worked. I realized now that several people are using or trying to use this service with Spring Websockets. Many of them facing difficulties. I do not use that environment. It will be useful if you can contribute a guide on howto use this library with Spring. Also, I realized that some people are trying to use it using SockJS, which is not a great idea in this case. Your contribution will really help. :) |
There are some problems with setup I use that I still try to resolve, Mainly csrf token that I have to extract from cookie and put in stomp headers, problem is with doing it when upgrade request is first request. Once I have all working I'll upload some guide on how I did it. |
I am sure by now you have been able to configure and use the service. It will be really helpful if you will write a howto. Many thanks! |
I have spring backend and Angular 2 frontend with websocket communication between. Part of my app have to be accessible anonymously, and other part requires authentication. To achieve this I'd have to remake websocket connection after authentication, because spring security "hands over" authentication to websocket on Upgrade request.
I can disconnect using .disconnect() method, but how can I reconnect after?
The text was updated successfully, but these errors were encountered: