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

Need to connect to web socket server with cookie #495

Closed
djarvis opened this issue Dec 12, 2018 · 6 comments
Closed

Need to connect to web socket server with cookie #495

djarvis opened this issue Dec 12, 2018 · 6 comments
Labels
feature-request New feature or request

Comments

@djarvis
Copy link

djarvis commented Dec 12, 2018

I need to connect to a websocket server with the outgoing initial HTTP request containing a cookie. Is this possible? I didn't see any options in MqttClientOptionsBuilder.

@chkr1011
Copy link
Collaborator

I believe this is related to #496.

@djarvis
Copy link
Author

djarvis commented Dec 13, 2018

I was able to do this by creating a MqttClientWebSocketOptions class and attaching a CookieContainer, then assigning this to ChannelOptions of a manually created MqttClientOptions class.

In other words this is possible without using the builder, but it'd be nice if there was an override that included a cookie container on WithWebSocketServer() extension.

@cquesnel
Copy link
Contributor

Not sure, if cookies are passed through request headers, but while adding the option for headers, I will also add an overload for the CookieContainer. As @djarvis says, a MqttClientWebSocketOptions class could be passed in the builder the same way as is done with MqttClientOptionsBuilderTlsParameters.

All while leaving the default call with only the url for backwards compatibility

@djarvis
Copy link
Author

djarvis commented Dec 13, 2018

I just tested this and I do get cookies back to the client from the connect call, and when I set them they are also recognized on the server.

I am doing this because, in scaled Azure instances, I wish to target specific instances of my MQTT broker behind the load balancer. I can tell which instance the client is talking to by observing the ARRAffinity cookie in my cookie collection, and I can also target a specific instance to connect with by setting the cookie.

It's all wonderfully awesome.

@cquesnel
Copy link
Contributor

@djarvis I've just created a pull request allowing to pass the cookies and request headers if you want to check it out

@SeppPenner
Copy link
Collaborator

I assume that this is done. Please re-open this issue or comment if you have any concerns, @djarvis.

@SeppPenner SeppPenner added the feature-request New feature or request label Jun 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants