Skip to content

Could not connect with AWS graphQL client (Appsync APIs) #243

Open
@JackPriyan

Description

@JackPriyan

I am trying to implement the same example given below in python with .net and this grahQL-client nuget but I am always getting error that the "server closed the connection without a closing handshake".

https://aws.amazon.com/blogs/mobile/appsync-websockets-python/

The code in above sample is working good in python.

could any please help with this. I am trying to fix from last two week. Not sure its something inside the library or I am not able to use the library correctly.

My code looks like

var header = System.Convert.ToBase64String(Encoding.UTF8.GetBytes("{'host': '--HOST Name here--', 'x-api-key': '--APISYNC KEY HERE--'}"));
var gQL = new GraphQLHttpClient("--WEBSOCKET URL HERE--", new NewtonsoftJsonSerializer());
gQL.HttpClient.DefaultRequestHeaders.Add("header", header);

var request = new GraphQLHttpRequest{Query = "subscription SubscribeToEventComments{ subscribeToEventComments(eventId: 'test'){  content }}",OperationName = "SubscribeToEventComments", Variables = new{}};
IObservable <GraphQLResponse<string>> subscriptionStream = gQL.CreateSubscriptionStream<string>(request, (Exception ex)=>{
Console.WriteLine(ex.ToString());
});
var subscription = subscriptionStream.Subscribe(response =>
{
Console.WriteLine($"user '{Newtonsoft.Json.JsonConvert.SerializeObject(response)}' joined");
},
ex=>{
Console.WriteLine(ex.ToString());
 });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions