Skip to content
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

connectUrl is re-generated each time when it is called #95

Closed
MacDeveloper1 opened this issue Jan 29, 2024 · 6 comments
Closed

connectUrl is re-generated each time when it is called #95

MacDeveloper1 opened this issue Jan 29, 2024 · 6 comments

Comments

@MacDeveloper1
Copy link
Contributor

The version before 1.0.0 has a url value which was initialized once using SockJsUtils().generateTransportUrl when useSockJS was set to true. In next versions you created a getter connectUrl which returns the effective transport URL for each connection. I think it should be unique and permanent for new STOMP connection during the session but now connectUrl is re-generated each time this getter is called.

@KammererTob
Copy link
Contributor

KammererTob commented Jan 29, 2024

Hi,

according to the SockJS spec the session_id needs to be unique for every session:

Second parameter session_id must be a random string, unique for every session.

So i think this behavior is correct. Do you have a specific issue/use-case as to why you need this to be identical? I am not sure if a reconnect should be considered a new session or not, which is the only scenario i currently can think of where the new generation would not be desirable (although that might still lead to other issues)

@MacDeveloper1
Copy link
Contributor Author

MacDeveloper1 commented Jan 29, 2024

Yes. It should be unique for every session but it also should be permanent for such session, i.e. value should be idempotent.

final client = StompClient(); // single session
// somewhere on connecting status
print(client.connectUrl); // one value
// somewhere on connected status
print(client.connectUrl); // second value
// somewhere on disconnected status
print(client.connectUrl); // third value

But it should be the same as it is the same client and same session.

Let'say I save websocket clients for some other actions in Map where key is connectUrl. Then I never find the value for a key as it always changed.

@KammererTob
Copy link
Contributor

Thanks. So if i understand correctly you want to have it return the same value that was used while connecting. So it should only regenerate if it actually is in the process of connecting. Correct? If yes, then that is probably reasonable.

@MacDeveloper1
Copy link
Contributor Author

MacDeveloper1 commented Jan 29, 2024

So it should only regenerate if it actually is in the process of connecting

Yes. Correct. As site has its own URL, then the WS connection should have its unique connectUrl during the life. And it can be used as its name for identity somewhere (in logs for example).

@MacDeveloper1
Copy link
Contributor Author

I created a PR #96. Maybe you can have a quick look if this looks good to you?

@KammererTob
Copy link
Contributor

@MacDeveloper1 I have released a new version including this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants