I am making an application in Xamarin Forms that uses the Signalr service to implement a chat. The chat works perfectly in the UWP version and in the Android emulator, so it does when I am debugging on my phone (Android), but when I disconnect the phone from the PC the chaos begins. The problem is that I think that when the application goes to the background, it disconnects from the Signalr server.
我尝试过自动重新连接,甚至更改 ServerTimeout 和 KeepAliveInterval 的时间。但我没有成功。应该注意的是,我住的地方还有主要的连接问题,但我的理论仍然是应用程序进入后台时。
这是我初始化服务的代码(我使用的是单例服务)。
hubConnection …Run Code Online (Sandbox Code Playgroud)