我正在使用 SuperSocket 套接字服务 (SuperSocket.SocketService.exe) 作为我的 Silverlight 策略服务器,但该服务没有被命中并且我的策略没有返回。但是,我可以通过 Hercules 连接到该服务。
我已启用内置 Flash Silverlight 策略服务器,方法是将其添加到我的配置文件中,如此处所述。SuperSocket.Facility.dll 与其他 3 个必需的 dll 一起存在于我的服务的运行目录中。
服务配置文件:
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="superSocket" type="SuperSocket.SocketEngine.Configuration.SocketServiceConfig, SuperSocket.SocketEngine" />
</configSections>
<appSettings>
<add key="ServiceName" value="SupperSocketService" />
</appSettings>
<superSocket>
<servers>
<server name="SilverlightPolicyServer"
serverType="SuperSocket.Facility.PolicyServer.SilverlightPolicyServer, SuperSocket.Facility"
ip="Any" port="943"
receiveBufferSize="32"
maxConnectionNumber="100"
policyFile="D:\policyserver\SLPolicy.xml"
clearIdleSession="true">
</server>
</servers>
</superSocket>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
策略服务器启动正常:
来自 Silverlight 的连接失败:
var webSocketClient = new WebSocket(string.Format("ws://127.0.0.1:{0}/websocket", 943, "basic", version));
webSocketClient.Opened += new EventHandler(webSocketClient_Opened);
webSocketClient.Closed += new EventHandler(webSocketClient_Closed);
webSocketClient.DataReceived += new EventHandler<DataReceivedEventArgs>(webSocketClient_DataReceived);
webSocketClient.MessageReceived += new EventHandler<MessageReceivedEventArgs>(webSocketClient_MessageReceived);
if (autoConnect)
{
webSocketClient.Open();
if (!OpenedEvent.WaitOne(1000))
throw new Exception("Cannot connect...");
}