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://learn.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.

Michael Xu
  • 4,382
  • 1
  • 8
  • 16
Uwe
  • 13
  • 1
  • You may need to use computer name instead of IP. For IP to work you need a route from client to server and from server to client. It is possible for one direction to work and not the other. So best thing to do is from cmd.exe >Ping IP or Computer Name. You first have to get PING to work which tests a route (ping ignores the port number). Try ping in both directions.If it doesn't work then try intermediate PC to see what works and what doesn't.Any try both IP and computer name. It is possible you have two PC with same IP. If ping works. disconnect working PC to see if you still work. – jdweng Feb 23 '20 at 20:27
  • @Uwe, did you add a firewall rule ot the server port for allowing the communication in Raspberry PI? Many users caused the same issue du to miss the firewall rule. Please refer to this topic(https://stackoverflow.com/questions/36502484/uwp-raspberry-pi-webserver-issue). – Michael Xu Feb 24 '20 at 07:49
  • @jdweng: I tried ping by address and name. Works from both ends. Comment: when using the PC/RPI name, seems automatically IP V6 is resolved and ping does not work. When forcing ping -4 it resolves IPV4 and ping works. This gives me a good hint for potential future problems. Thx a lot for your suggestion. – Uwe Feb 24 '20 at 18:46
  • @Michael Xu. Amazing!! That solved my problem. I opened the port on RPI and it works like a charm. I even don't have to open the port on PC side. Somehow I "wiped away my concern" about the firewall on Windows 10 IoT. I should have known or at least searched for it. Thanks a lot!!! – Uwe Feb 24 '20 at 18:50

1 Answers1

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

Uwe
  • 13
  • 1