C# server client fails on connect UWP (2)

0

I am facing a problem to connect my Windows 10 PC to a Raspberry Pi running Windows 10 IoT (17763, which seems to be the most recent one) via TCP. The RPI shall be the server and the Windows 10 PC the client.

I found the following Socket documentation: https://docs.microsoft.com/de-de/windows/uwp/networking/sockets which provides a well understandable UWP example. That example runs the server and client in just one application. Reasoning:

To begin with as few moving parts as possible—and to sidestep network isolation issues for the present—create a new project, and put both the client and the server code below into the same project.

That examples runs fine either on PC or on RPI. I tried it by a) using “localhost” and b) the individual IP addresses of the PC and RPI => OK.

I split the example into two applications and run the server on RPI and the client on the PC. Of course, I added the IP address of the RPI in the client

static string Server = "192.168.178.78";    // Raspberry PI
...
var hostName = new Windows.Networking.HostName(Server);

Unfortunately, the connection is not established and the client times out (error 0x8007274C) .

In Wireshark (on PC) I can see:

No.     Time           Source                Destination           Protocol Length Info
    320 34.221418      192.168.178.38        192.168.178.78        TCP      66     50198 → 1337 [SYN] Seq=0 Win=64240 Len=0 MSS=1460 WS=256 SACK_PERM=1

plus a number of re-transmissions. Since the connection does not work, I switched off the firewall on the PC. This doesn’t help either. Although port settings shouldn't matter, I opened TCP port 1337 on my router.

In the following thread, the same issue occurred, but this was due to running both applications on the same machine. Once Sven separated client and server to PC <-> mobile phone, it worked for him.

C# server client fails on connect UWP

I did a CheckNetIsolation.exe Debug session for Client and server. Both gave the following result (Remark: only one session listed here):

C:\WINDOWS\system32>CheckNetIsolation.exe Debug -p=S-1-15-2-1267940166-3928243817-861952377-2407264183-3106597897-3574865703-2117263357

Eine Netzwerkisolations-Debugsitzung wurde gestartet.
Reproduzieren Sie das Szenario, und drücken Sie dann STRG+C.
      Protokolle werden gesammelt........

Zusammenfassungsbericht

Status der Netzwerkfunktionen
----------------------------------------------------------------------
    InternetClient                Not Used and Insecure
    PrivateNetworkClientServer    Not Used and Insecure


Detaillierter Datenverkehrsbericht
----------------------------------------------------------------------

    InternetClient                Not Used and Insecure

 ------------------------------------------------------------------


    PrivateNetworkClientServer    Not Used and Insecure

 ------------------------------------------------------------------
OK

Any idea? I would highly appreciate proposals to fix that issue.

c#
tcp
uwp
client-server
windows-iot-core-10
asked on Stack Overflow Feb 23, 2020 by Uwe • edited Feb 24, 2020 by Michael Xu - MSFT

1 Answer

0

Refer to Michael Xus comment. The port on the Raspberry Pi had to be opened by

netsh advfirewall firewall add rule name="pidart port 1337" dir=in action=allow protocol=TCP localport=1337

This solved the issue

answered on Stack Overflow Feb 24, 2020 by Uwe

User contributions licensed under CC BY-SA 3.0