Skip to content

subscribing to several subscriptions throws an InvalidOperationException #260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pdufrene opened this issue Jul 27, 2020 · 0 comments · Fixed by #266
Closed

subscribing to several subscriptions throws an InvalidOperationException #260

pdufrene opened this issue Jul 27, 2020 · 0 comments · Fixed by #266
Labels
bug Something isn't working

Comments

@pdufrene
Copy link

Hi,

I am using version 3.1.3 of GraphQLClient and in my code I am subscribing to several subscriptions:

var stream1= graphQLClient.CreateSubscriptionStream<JToken>(new GraphQLRequest { Query = query1, WebSocketExceptionHandler);
subscription1 = stream1.Subscribe(stream1OnNext);

var stream2= graphQLClient.CreateSubscriptionStream<JToken>(new GraphQLRequest { Query = query2, WebSocketExceptionHandler);
subscription2 = stream2.Subscribe(stream2OnNext);

And when I execute this I receive the following exception:

System.InvalidOperationException
  HResult=0x80131509
  Message=There is already one outstanding 'SendAsync' call for this WebSocket instance. ReceiveAsync and SendAsync can be called simultaneously, but at most one outstanding operation for each of them is allowed at the same time.
  Source=System
  StackTrace:
   at System.Net.WebSockets.WebSocketBase.<SendAsyncCore>d__47.MoveNext()

When the second call to CreateSubscriptionStream is made.

If I debug step by step, it's working fine. How could I know that the web socket is ready?

@pdufrene pdufrene changed the title subscibing to several subscriptions subsribing to several subscriptions throws an InvalidOperationException Jul 27, 2020
@pdufrene pdufrene changed the title subsribing to several subscriptions throws an InvalidOperationException subscribing to several subscriptions throws an InvalidOperationException Jul 27, 2020
@rose-a rose-a added the bug Something isn't working label Aug 8, 2020
@rose-a rose-a mentioned this issue Aug 24, 2020
rose-a added a commit that referenced this issue Aug 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants