none
Communication between UWP server and .NET client

    Question

  • Hi,

    I have lot of problems trying to create a server-client project for my Raspberry Pi. I want to send data using UDP from my server to connected mobile clients that are not in local network. First problem is that sending any data from clients using UdpClient class, server that uses DatagramSocket is not working until server sends data first. In release, clients' endpoints will be unknown for server... I have found that there is a workaround for this issue, but it seems to work only with multicasting and it isn't an option in my case.

    I tried to make a connection using TCP using StreamSocketListener on server side and TcpClient on clients side, but client cannot reach server, I always get an exception saying "A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.".

    My TCP server code:

                _tcpServer = new StreamSocketListener();
                _tcpServer.ConnectionReceived += ClientCheck;
                await _tcpServer.BindServiceNameAsync("9090");

    TCP client is throwing exception on TCPClient's constructor with server IP as hostname and same port as above.

    Question is, does anyone have an working example of using networking between UWP application and any other framework/technology?

    • Moved by IoTGirl Wednesday, March 22, 2017 10:29 PM Not an IoT Question
    Thursday, March 16, 2017 9:58 PM

Answers

All replies

  • hello

    have you opened the required port(s) on your device firewall?

    br
    Andre


    Thursday, March 16, 2017 10:15 PM
  • Hi,

    yes, ports are opened. I should mention that I test my server and client on same machine and I use 127.0.0.1 address as host. I created simple server application using windows forms and I can confirm that my client is ok, so the problem must be in UWP server.

    I have Internet (Client) and Internet (Client & Server) capabilities on. Should I set some other configs? Is there something else I need to add to UWP server to get it working?

    Friday, March 17, 2017 7:10 PM
  • .... I should mention that I test my server and client on same machine and I use 127.0.0.1 address as host. I created simple server application using windows forms and I can confirm that my client is ok, so the problem must be in UWP server....

    is the "simple server app using windows forms" what you define as "my client is ok"

    how is your pi connected?

    i don't think UWP supports access from localhost/127.0.0.1 for security reasons

    Friday, March 17, 2017 7:55 PM
  • I didn't deploy any application on Raspberry Pi yet, sorry for confusion. By same machine, I meant my development PC. I test all applications from Visual Studio if that matters.

    Currently I focus on UDP communication and I have 3 applications now: UWP server, Win Forms server and Win Forms client. All tests are done on mentioned PC. When Win Forms server is on, my client is able to send/receive data. When UWP server is on, my client cannot send data to server until server sends data first. After that communication works in both ways.

    Like I said in first post, I have found workaround for this known issue, but it seems it works only when using multicast UDP (correct me if I am wrong) and it isn't option for me.

    Saturday, March 18, 2017 10:34 AM
  • hello

    "When UWP server is on, my client cannot send data to server until server sends data first. After that communication works in both ways."

    expected behavior because Client and Server is running on the same machine and UWP has some security restrictions

    "I didn't deploy any application on Raspberry Pi yet, sorry for confusion. By same machine, I meant my development PC. I test all applications from Visual Studio if that matters."

    so Developing Universal Windows apps seems the better forum for your issue

    br
    Andre

    Saturday, March 18, 2017 10:42 AM
  • Hi Korush,

    I have moved this question to the "Where is the forum for" topic as I am not sure where to re-route your question as it includes UWP, Winforms and Client/Server.

    Hopefully a forums moderator here can help you find the correct forum for your question as you are not asking about Windows IoT but instead code running on a Windows Desktop.

    Sincerely,

    IoTGirl

    Wednesday, March 22, 2017 10:32 PM
  • Might try them over here.

    https://social.msdn.microsoft.com/forums/windowsapps/en-us/home?forum=wpdevelop%2Cwindowsgeneraldevelopmentissues%2Cwinforms&filter=alltypes&sort=lastpostdesc

     

     



    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows Server] Datacenter Management

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.

    Wednesday, March 22, 2017 10:44 PM
    Moderator