graphql-platform icon indicating copy to clipboard operation
graphql-platform copied to clipboard

#strawberry-shake how can I reconnect websocket if somehow Server is Restarted and connection is lost

Open ibnekhalid opened this issue 4 years ago • 15 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues

Describe the bug

#strawberry-shake how can I reconnect websocket if somehow Server is Restarted and connection is lost

There should be onConnect and OnDisconnet events callbacks.

Steps to reproduce

My Startup as per documentation

services.AddBkClient(profile: BkClient.BkClientProfileKind.Default).ConfigureHttpClient((sp , client) => { var login = sp.GetService<Login>( ); _token = login.GetAccessToken( ); client.BaseAddress = new Uri(_appSettings.BkQueryUrl); client.AddBearerToken(_token); }).ConfigureWebSocketClient((sp , client) => { client.Uri = new Uri(_appSettings.BkWsUrl); });

Relevant log output

No response

Additional Context?

No response

Product

Strawberry Shake

Version

11.3.5

ibnekhalid avatar Sep 03 '21 15:09 ibnekhalid

@tobias-tengler Do we have any work around for now? To reconnect websocket and getting subscriptions live.

ibnekhalid avatar Sep 04 '21 08:09 ibnekhalid

We will have a look at this issue next week.

michaelstaib avatar Sep 07 '21 22:09 michaelstaib

The GraphQL.Net client exposes a WebsocketConnectionState property that can be subscribed to. This is super useful when you need to synchronize data after connectivity issues. Would be great if Strawberry Shake could offer something similar

jonbmul avatar Sep 08 '21 21:09 jonbmul

@ibnekhalid i have an open issue with subscriptions as well. #4303 I made an example to demonstrate the issue.

This example also contain a workaround for broken connection detection. Maybe it is helpful for you as well. https://github.com/horego/hotchocolate-graphql-examples realized with an DeadSocketConnectionInterceptor

best regards

horego avatar Oct 08 '21 08:10 horego

@horego thanks, but for now i have implemented SignalR (with websocket connection) until the issue is not resolved. Once the issue would be resolved i would move to the #StrawberryShake Subscriptions again.

ibnekhalid avatar Nov 01 '21 06:11 ibnekhalid

@horego, You are observing socket connection on Client side only but i need to capture Disconnect on Server also.

ibnekhalid avatar Nov 01 '21 07:11 ibnekhalid

@michaelstaib, i know you people are working on other millstones also. Are you people done with this issue?

Thanks?

ibnekhalid avatar Nov 01 '21 07:11 ibnekhalid

I have a interim solution. Look at #5006 .

CoreDX9 avatar Apr 26 '22 08:04 CoreDX9

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jun 25 '22 16:06 stale[bot]

This issue make the whole feature of subscriptions more or less unusable, no? That's great for things that complete in a short time, but for any long lived subscriptions, an absence of automatic reconnexion / notification mechanism is really wrong. :/ Does something prevent to apply the CoreDX9 solution of completing the subscription on case of disconnection?

Need to add that the two workarounds I've found here seem outdated and does not work properly.

fhewitt avatar Mar 17 '23 13:03 fhewitt

@fhewitt do you want to help on this? We have started work on a new underlying socket handling but any help is welcome.

michaelstaib avatar Mar 20 '23 14:03 michaelstaib

I am facing connection issues as well and trying to figure out how to reconnect the websocket connection. For cases when internet drops or when auth token expires, I wanted to be able to check and reconnect if the web socket connection is disrupted or if not successful. I also notice that the WebSocket client's state would go on Aborted state and have no clue why when how that happened.

I tried the GraphQL.Net client and did not face these issues. Would be great if Strawberry Shake can have an OnError or OnDisconnected event or an observable that can subscribed to so that a proper handling can be done.

Much better if it would reconnect automatically.

JenMQ avatar May 15 '23 05:05 JenMQ

I am facing connection issues as well and trying to figure out how to reconnect the websocket connection. For cases when internet drops or when auth token expires, I wanted to be able to check and reconnect if the web socket connection is disrupted or if not successful. I also notice that the WebSocket client's state would go on Aborted state and have no clue why when how that happened.

I tried the GraphQL.Net client and did not face these issues. Would be great if Strawberry Shake can have an OnError or OnDisconnected event or an observable that can subscribed to so that a proper handling can be done.

Much better if it would reconnect automatically.

I am running into the same issue. where is able to identify a solution or a workaround?

gowthambala avatar Jul 25 '23 15:07 gowthambala

@gowthambala unfortunately, we had to postpone the usage of strawberry shake on our project due to the issue mentioned above. But now, we have to try again but looks like there are no fixes/updates made yet.

JenMQ avatar Jul 28 '23 06:07 JenMQ

@fhewitt do you want to help on this? We have started work on a new underlying socket handling but any help is welcome.

@michaelstaib are there any updates on possible solution/workaround for the reconnection issue?

JenMQ avatar Jul 28 '23 06:07 JenMQ

@JenMQ - did you get this working?

datoon83 avatar Mar 15 '24 09:03 datoon83