Closed taroyutao closed 4 years ago
What is your client id? I mean, the error says: ClientIdentifierNotValid
. Maybe something is wrong there or you are using some not supported char maybe?
Another hint might be that you're trying to use SSL on port 1883? I don't know if this is intended, but normally 8883 is the SSL port for MQTT over SSL...
As this issue is open quite long and you didn't answer my question (We need more information to help you out), I will close this issue now. Just write another message here if this still occurs and (if possible provide more information to us).
@SeppPenner I'm having the same issue as the user above, we're both connecting to the same broker it seems.
The clientIds for aliyuncs brokers are a bit long, here's an example:
123456|securemode=3,signmethod=hmacsha1,timestamp=1598679202|
Using the same settings in MQTT.fx it works fine.
@SeppPenner disregard, after further investigation of the CONNECT packet between MQTT.fx and what was being generated by MQTTnet I noticed the KeepAlive period was the only thing different.
aliyuncs has a requirement that the KeepAlive period is at least 30 seconds. If it's any less it will return an InvalidClient error.
Keep this ticket closed, thank you.
Describe your question
I user MQTT.fx with username、password、port and broker url connect my own mqtt broker,everything works fine.
But when I use this Client with the same infomation, it doesn't work.
Code: string ServerUrl = "***.iot-as-mqtt.cn-shanghai.aliyuncs.com"; string UserName = "**"; string Password = "**"; string clientId = "**"; var options = new MqttClientOptionsBuilder() .WithClientId(clientId) .WithTcpServer(ServerUrl,1883) .WithCredentials(UserName, Password) .WithTls() .WithCleanSession() .Build();
The error info: MQTTnet.Adapter.MqttConnectingFailedException HResult=0x80131500 Message=Connecting with MQTT server failed (ClientIdentifierNotValid). Source=MQTTnet StackTrace: at MQTTnet.Client.MqttClient.d40.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MQTTnet.Client.MqttClient.d 33.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at MQTTnet.Client.MqttClient.d__33.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at ConsoleApp1.Program.Main(String[] args) in C:\Users\Administrator\source\repos\MQTTDemo\ConsoleApp1\Program.cs:line 30
Which project is your question related to?
Can you give me some advices, thanks.