2016-07-29 19 views
0

クライアントにサーバーサイドイベントとしてServerEventsClientを使用しています。現在、サーバーをシャットダウンした場合、クライアントは再び使用可能になったときに自動的に再接続しません。ServiceStack ServerEventsClient自動再接続

自動的に接続しようとしますか?

答えて

0

私たちのテストではアプリケーションサーバーを再起動したときにServerEventsClientは自動再接続を行い、ここで私たちが使用する簡単なテストだということを示してください:

var client = new ServerEventsClient("http://localhost:11001", "home") 
{ 
    OnConnect = ctx => "OnConnect: {0}".Print(ctx.Channel), 
    OnCommand = msg => "OnCommand: {0}".Print(msg.Data), 
    OnException = ex => "OnException: {0}".Print(ex.Message), 
    OnMessage = msg => "OnMessage: {0}".Print(msg.Data), 
    OnHeartbeat =() => "OnHeartbeat".Print() 
}; 

client.Handlers["chat"] = (source, msg) => 
{ 
    "Received Chat: {0}".Print(msg.Data); 
}; 

await client.Connect(); 

そしてAppServerには、それが接続されていたときにServerEventClientの自動再接続を示すログ再起動された:あなたが問題を再現するコードがある場合

OnConnect: 
OnCommand: [email protected] {"userId":"-2","isAuthenticated":"false","displayName":"user2","channels":"home","profileUrl":"https://raw.githubusercontent.com/ServiceStack/Assets/master/img/apps/no-profile64.png"} 
OnHeartbeat 
Received Chat: [email protected] {"id":1,"fromUserId":"-1","fromName":"user1","message":"1","private":false} 
OnMessage: [email protected] {"id":1,"fromUserId":"-1","fromName":"user1","message":"1","private":false} 
Received Chat: [email protected] {"id":2,"fromUserId":"-1","fromName":"user1","message":"2","private":false} 
OnMessage: [email protected] {"id":2,"fromUserId":"-1","fromName":"user1","message":"2","private":false} 
OnHeartbeat 
OnHeartbeat 
OnException: The remote server returned an error: (404) Not Found. 
OnConnect: 
OnCommand: [email protected] {"userId":"-3","isAuthenticated":"false","displayName":"user3","channels":"home","profileUrl":"https://raw.githubusercontent.com/ServiceStack/Assets/master/img/apps/no-profile64.png"} 
Received Chat: [email protected] {"id":1,"fromUserId":"-2","fromName":"user2","message":"1","private":false} 
OnMessage: [email protected] {"id":1,"fromUserId":"-2","fromName":"user2","message":"1","private":false} 
Received Chat: [email protected] {"id":2,"fromUserId":"-2","fromName":"user2","message":"2","private":false} 
OnMessage: [email protected] {"id":2,"fromUserId":"-2","fromName":"user2","message":"2","private":false} 
OnHeartbeat 
OnHeartbeat 

ServiceStack's Issue Trackerにそれを提出してください。

関連する問題