Open Socket Silverlight 5 AccessDenied

I have a Silverlight 5 application trying to establish a socket connection with a server as follows:

var targetEndpoint = new DnsEndPoint("subdomain.maindomain.com", 443);
var clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
var socketAsyncEventArgs = new SocketAsyncEventArgs {RemoteEndPoint = targetEndpoint};
socketAsyncEventArgs.Completed += AsyncConnectCallback;
clientSocket.ConnectAsync(socketAsyncEventArgs);

I have the following clientaccesspolicy.xml file in https://subdomain.maindomain.com/clientaccesspolicy.xml:

<access-policy>
    <cross-domain-access>
        <policy>
            <allow-from http-request-headers="*" http-methods="*">
                <domain uri="https://subdomain.maindomain.com"/>
                <domain uri="*"/>
            </allow-from>
            <grant-to>
                <resource path="/" include-subpaths="true"/>
                <socket-resource port="4502" protocol="tcp"/>
            </grant-to>
        </policy>
    </cross-domain-access>
</access-policy>

I can start a local Silverlight application instance from visual studio and establish a socket connection that works both in the browser and outside the browser. When I deploy the application, I can still connect using a version other than the browser, but there are errors in the browser with the following message:

AccessDenied: An attempt was made to access a socket in a way forbidden by its access permissions.

In my local environment, where I run Visual Studio if I create a hosts file entry:

127.0.0.1 myapp.local

localhost ( VS), myapp.local, , , , localhost, , .

, , .

- , ?

+4
2

, "Relaxed Cross-Domain Access Restrictions" , , , , " ".

, , , Application.HasElevatedPermissions true.

, 943

, , , - , 4502 4534.

0

Source: https://habr.com/ru/post/1664198/


All Articles