-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't restart connection after disconnect #71
Comments
This is currently by design. Once the connection is stopped it cannot be started. Currently, you will have to create a new connection each time you want to connect to the server. Having said that, I admit that doing this and getting it right is challenging. I started thinking on making the connection re-usable/restartable but it is actually more challenging than changing the condition you pointed to.
What are the scenarios you need it for? |
@moozzyk i am implementing a chat application with your library. Beautiful job you have done i must say but the only challenge i am having is because the connection times out and i have to reopen it everytime...I just put my methods in the viewWillAppear()...but then it is bad userExperience meaning it has to reload all the messages and conversation again anytime a user leaves the messaging tab. |
@blavkjay - I think you are discussing a few issues hereL
I have an impression that the connection is being closed because it goes out of scope and is being deinitialized. Make sure you keep a reference to your
In general this should not happen. The underlying connection is using webSockets and the webSocket protocol by default tries to ensure that the connection stays alive. If you see frequent time outs (not really sure what it means - is this disconnects?) the problem can be on the client or on the server. I would recommend turning on logging at the debug level on the client to see what error you get. |
Hi @moozzyk , thanks for this beautiful library. |
Currently the connection is not reusable - you need to create one before starting. Normally it is not a big issue. It gets however tricky when trying to handle error cases where you would like to try to reconnect to the server after connection was lot. I have started working on a reconnectable connection in this branch: https://github.com/moozzyk/SignalR-Client-Swift/tree/reconnect but it is not yet ready. When it's ready it should also make it possible to restart connections. |
ok Thanks, so in case you have described(lost connection) will I get notification in any of this methods? |
I just faced a problem, when I am stopping and starting connection 10 times in a small period of time app freezes( for example when app moves to background and moves back to foreground), can you suggest anything related to this? UPD 1 UPD 2 |
Thanks for the update! This is a good find - I have not seen it but I am glad it was found before I merged it back to master. I opened a separate issue to track this #86. Could you turn on logging at the debug level and attach logs to the issue I created? |
@apphardtask - if this is in a function then when function completes its execution the |
I believe the original question was answered. The reconnect issue is being tracked as #86 and I think it should be resolved now. |
@moozzyk , I have implemented "https://github.com/AutosoftDMS/SignalR-Swift" this in our project , but what is the difference between yours library and AutosoftDMS/SignalR-swift, and the issue is with this library is we are unable to get the call back whether the connection is closed or disconnected, because of that we cant start a new connection due to this request time out happening, and also we are unable to implement your library into our project because you have not provided full code on this, please write a entire class to implement your library and reconnection logic . |
I am not too familiar with AutosoftDMS/SignalR-swift but at first glance, it is meant for the old (non-ASP.Net Core) of SignalR. This client works with the ASP.Net Core version of SignalR. I don't believe there is any significant functionality missing in this implementation. Please do not comment on unrelated and closed issues but open a new issue. |
Connection was stopped after internet disappeared (or any another reason). I want to restore connection by command connection.start, but get fail "Starting connection failed - invalid state". That means that connection can't started because it's current state is 'stopped', not 'initial'. (func start() in HttpConnection.swift). Also I can't get current state (if now is not in 'connected') to force stop and start connection.
I think need change logic to like:
if changeState(from: .initial || .stopped, to: .connecting) == nil {
And would be good to make public state of connection. Thank you.
The text was updated successfully, but these errors were encountered: