Signal R in react naive losses connection when app goes in background after some time.

Sumit Kale 1 Reputation point
2021-10-12T12:44:52.917+00:00

I have integrated Signal R Library for my react native application. when the app is foreground I can easily establish a connection with signal R consumer from my signal R client. but when the app goes in background connection is maintained for few seconds and it's disconnected. I try to reconnect, establish a new connection still, it's giving me an error "Connection disconnected with error Error: Error occurred" disconnected and nothing happens. I tried even on the basis of state management that we can establish a connection when the app goes in the background but getting the same error. Please suggest any solution and if have any example that will best for understanding.

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,570 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 69,806 Reputation points
    2021-10-12T15:05:11.403+00:00

    Signal/r requires a persistent websocket connection. This won’t work with a background task which is put to sleep. You are allowed a fetch on a timer.

    If you want the background task to be notified by the server you need use the mobile remote notification services. While the server api is different for iOS and android, both azure and aws have gateways.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.