user7938219
user7938219

Reputation:

UWP client socket block when try to connect on Java server (release mode)

I have a UWP StreamSocket client writted in C # on Windows and I have a Java server socket listening on port 8080.

In Visual Studio, in debug mode, all work very well, my server received good data. But, in release mode, the app is unable to connect to a socket.

I have added modes : internetClient, internetClientServer and privateNetworkClientServer into Package.appxmanifest file but there are no improvements.

Here is my code to connect to a socket host = 127.0.0.1 and port = 8080 for the test

public async Task ConnectSocket(string host, string port)
{
    try
    {
        socket = new StreamSocket();
        socket.Control.KeepAlive = true;
        HostName hostName = new HostName(host);
        await socket.ConnectAsync(hostName, port);
    }
    catch (Exception ex)
    {
        //....
    }
}

What is the problem and how can I repair this ?

Upvotes: 1

Views: 174

Answers (1)

Sunius
Sunius

Reputation: 2907

You need to enable loopback for your UWP application. When you run in VS, it does it for you. When you run without VS, you need to do it yourself.

https://learn.microsoft.com/en-us/windows/iot-core/develop-your-app/loopback

Upvotes: 1

Related Questions