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

Connection with Web socket #52

Closed
emmanuelbertho opened this issue Jun 15, 2023 · 2 comments
Closed

Connection with Web socket #52

emmanuelbertho opened this issue Jun 15, 2023 · 2 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@emmanuelbertho
Copy link

Hello,

I am trying to connect to a broker with web socket and I think there is an error in the connection method in SparkplugNodeBase.cs line 296.

I think in builder.WithWebSocketServer(this.Options.BrokerAddress, this.Options.WebSocketParameters); the first parameter shouldn't be just the broker address but {brokerAdress}:{port}.

I tested the modification and it works on my side.

Emmanuel

@SeppPenner SeppPenner self-assigned this Nov 27, 2023
@SeppPenner
Copy link
Owner

SeppPenner commented Nov 28, 2023

I'm not 100 percent sure, this depends on how you want to reach your websocket, e.g. if there is a connection like mqtt.eclipseprojects.io:443/mqtt, this would not work. Maybe I can add something like this:

if (this.Options.BrokerPort is null)
{
    builder.WithWebSocketServer(this.Options.BrokerAddress, this.Options.WebSocketParameters);
}
else
{
    builder.WithWebSocketServer($"{this.Options.BrokerAddress}:{this.Options.BrokerPort}", this.Options.WebSocketParameters);
}

@SeppPenner SeppPenner added bug Something isn't working enhancement New feature or request labels Nov 28, 2023
@SeppPenner
Copy link
Owner

I'm not 100 percent sure, this depends on how you want to reach your websocket, e.g. if there is a connection like mqtt.eclipseprojects.io:443/mqtt, this would not work. Maybe I can add something like this:

if (this.Options.BrokerPort is null)
{
    builder.WithWebSocketServer(this.Options.BrokerAddress, this.Options.WebSocketParameters);
}
else
{
    builder.WithWebSocketServer($"{this.Options.BrokerAddress}:{this.Options.BrokerPort}", this.Options.WebSocketParameters);
}

This doesn't work as I want to keep 1883 as default TCP port...

I have added a new hint here: https://github.com/SeppPenner/SparkplugNet/blob/master/HowToUse.md#connection-via-websocket-to-mqtt-server. Since I want to keep 1883 as default port for TCP (and I'm not sure how I should handle the WebSocket scenario with that precondition, my recommendation would be to specify the complete url (e.g. mqtt.eclipseprojects.io:443/mqtt or maybe test.something.com:443) as option for BrokerAddress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants