Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not able to connect to remote server from WinRT

I'm making an application which basically just needs to send a piece of XML to a server and return. I'm having trouble however getting this to work and getting very strange errors

public bool Post(string data)
    {
        string server="http://my-lan-computer:9091/foo"
        bool success = false;
        HttpClient client = new HttpClient();

        try
        {
            client.PostAsync(server, new StringContent(data, Encoding.UTF8, "text/xml")).Wait(); //error here
            success = true;
        } catch { }

        return success;

    }

The server I'm posting to is not localhost, but it is a computer on my local network. I get this error deeply nested:

innerException: {"An error occurred while sending the request."}

innerException: {"Unable to connect to the remote server"}

innerException: {"An attempt was made to access a socket in a way forbidden by its access permissions 123.123.123.123:9091"}

I have the internet client capability on my application. I can access my local network and internet by other store applications. I can access the resource in firefox get proper behavior. I don't have a firewall enabled nor an anti-virus that would block these ports

What could possibly cause this obscure error? How can I fix it?

like image 724
Earlz Avatar asked Jan 29 '13 21:01

Earlz


1 Answers

To access the LAN, you must declare the Private Network capability in your application manifest. Note that this is different than the Internet capability.

like image 134
chue x Avatar answered Oct 15 '22 03:10

chue x