Closed danielstock closed 4 years ago
Hi, thank you for reporting the issue. This is indeed a bug in the standalone MQTTnet.Server. This will be fixed in the next version (3.0.11). Best regards Christian
@chkr1011 thanks.
@chkr1011 i saw the uploaded files of js examples. but it's still not working,
i updated mqttnet nuget package from 3.09 to 3.0.11, and my program code is as following:
var optionsBuilder = new MqttServerOptionsBuilder()
.WithConnectionBacklog(100)
.WithDefaultEndpointPort(1883)
.WithConnectionValidator(c =>
{
c.ReasonCode = MqttConnectReasonCode.Success;
}).WithSubscriptionInterceptor(c =>
{
// if (context.TopicFilter.Topic == "x")
c.AcceptSubscription = true;
}).WithApplicationMessageInterceptor(c =>
{
//c.ApplicationMessage.Payload = new byte[]...
c.AcceptPublish = true;
});
// create mqtt server. _mqttServer = new MqttFactory().CreateMqttServer(); await _mqttServer.StartAsync(optionsBuilder.Build());
is there anything i'm missing?
thanks.
Well you need a Asp.net project. A plain console application with mqttnet only will not work. Check out the mqttnet server project for more details or checkout the wiki. There are also some examples.
@chkr1011 thanks. you mean integration with asp.net.core ?
Describe your question
i wrote a console application with mqttnet.server. mqtt.fx client connected to it successfully.
then i tried to use java script in web browser (paho-mqtt/1.0.1/mqttws31.min.js) the code is quite simple: var cid= (Math.random() * 1000000000).toString(); var client = new Paho.MQTT.Client('127.0.0.1', Number(8222), cid); client.onConnectionLost = onConnectionLost; ... but i got the following response: mqttws31.min.js:36 WebSocket connection to 'ws://127.0.0.1:8222/mqtt' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
so is there anyway i could do this using mqttnet.server (i expect the server to run in command line), other than using mqttnet.asp.net.core ?
thanks a lot
Which project is your question related to?