-
Notifications
You must be signed in to change notification settings - Fork 1k
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 refused on android #690
Comments
Did you gave the app the proper permissions? Maybe opening a server (port) requires additional permissions. |
i gave interner permission and network state and installed mqttnet in android project too. |
I had the same problem on BeagleBoardx15 running Linux Debian |
@denisgeom Okay, this is interesting... |
@denisgeom thanks. one question...it's possibile set your code in library without modify source code? |
@reiterasrls At the moment you can set NoDelay to false in the MQTT Server options. Then the failing method is not called. @denisgeom Are you sure that your mentioned solution is correct? I am not sure what the difference in using TCP instead of Socket as the parameter is. All examples I found are using the Socket parameter. |
I am guessing, since you open the socket as TCP, you may only change socket option for TCP. Leaving, SocketOptionLevel.Socket will generate access denied exception. |
You are right. I found this: https://docs.microsoft.com/en-us/dotnet/api/system.net.sockets.socket.setsocketoption?view=netframework-4.8 There TCP is used for NoDelay... |
thank you all |
Please try the latest beta I released yesterday. It contains a fix. |
I did try the latest NuGet package 3.0.6-beta1 and it does not crash anymore when opening the server on Linux and Windows |
I try it and let you know, thanks for all |
i tried beta release. now with the same code and now i have always socket exception "address already in use" |
Let me try to build a small Xamarin sample. I never had the use case that a smartphone is the server... |
After doing some research I found that the default bound IP address is not supported in Android. So you have to use the actual address of the device. IPHostEntry ipHostInfo = Dns.GetHostEntry(Dns.GetHostName());
IPAddress ipAddress = ipHostInfo.AddressList[0];
var server = new MqttFactory().CreateMqttServer();
server.StartAsync(new MqttServerOptionsBuilder()
.WithDefaultEndpointBoundIPAddress(ipAddress)
.WithDefaultEndpointBoundIPV6Address(IPAddress.None)
.Build()).GetAwaiter().GetResult(); But I recommend to do some more research in order to better understanding of the implications. |
thanks...try it and inspect eventually problems |
@reiterasrls Please reopen the ticket if you experience problems. @SeppPenner Do you think the above snipped is a good thing for the Wiki? |
Yeah, that is a good idea. I will add this soon. |
Hi,i'm using mqttnet in xamarin forms project (android and uwp) as a server and xamarin forms android as a client.
Id i run server on uwp app it work well but if i run android server client receive connection refused from server.
can you help me to resolve it
I see that the problem is to start broker on android because return exception (access denied).
It' s possibile to not work broker on Android?
The text was updated successfully, but these errors were encountered: