Comments (6)
I'm trying to use this library for GraphQL subscriptions but getting the following error "Connection closed by the server".
After more investigating, I find out that the initial request /graphql does not contain content-type header that is seem mandatory for the server I'm connecting to. I believe this is a reason of this error.
Could you please advice?
Thanks a lot in advance
from graphql-client.
The Content-Type
header is irrelevant for a websocket connection (see also this stackoverflow thread).
Maybe your server needs some form of authentication?
from graphql-client.
Thank you so much on a response provided. Yes, you're right, the issue related to missing authentication:
However, I have set it via ConfigureWebsocketOptions
and also via HttpClient
as following:
But still getting this error.
Could you please advice?
Thank you in advance
from graphql-client.
Are u sure that is the authorization header your server expects? I've seen lots of different authorization variants, especially with GraphQL subscriptions (it's a bit like the wild west there...)
Please doublecheck the docs of your server how authentication/authorization with subscriptions work!
from graphql-client.
Yes, the server expects a bearer token.
It seems like an issue is caused by https redirection middleware (authentication header is not preserved on redirects). So, when I changed from ws:// to wss:// it starts to work.
from graphql-client.
Yeah, here we go: https://github.com/dotnet/runtime/blob/main/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/RedirectHandler.cs#L53-L54
from graphql-client.
Related Issues (20)
- MapConverter throws if extensions property is null
- .NET 8.0 Issue w/ SystemTextJsonSerializer HOT 1
- SendQueryAsync fails unless Uri has a trailing '/' HOT 1
- GraphQL.Client.Example fails with exception
- Subscription disposed but connection remains HOT 4
- first and take not working properly? HOT 2
- How to use Polly with this library? HOT 1
- AppSync's WS connection closing at initialization HOT 1
- Json Serialiser doesn't handle structs well and ignores type converters HOT 11
- Make it easier to use GraphQL’s constructor with HttpClient and only endpoint
- System.Text.Json.JsonException when parsing response from SendMutationAsync. HOT 1
- Please consider adding [StringSyntax("GraphQL")] attributes HOT 4
- Unused project reference to Newtonsoft.Json in GraphQL.Client.LocalExecution
- Variable parsing different between C# "GraphQLRequest" and json/webui HOT 6
- More samples please + Does this library support graphql-sse (server-sent events)? HOT 5
- WebSocket handler in GRAPHQL_TRANSPORT_WS protocol should not send GQL_COMPLETE when closing connection HOT 1
- How to add header in graphql response
- The HTTP request failed with status code OK HOT 1
- How to pass a list of "input Type" in variables HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphql-client.