altair: GraphQL subscriptions json error

I’m trying to implement GraphQL subscriptions but so far it doesn’t work. When I put the subscription query into Altair and click send, Altair immediately throws an error like this:

An error occurred in subscription.
Error: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data 

In firefox console I also see these errors:

Firefox can’t establish a connection to the server at ws://localhost:8080/.
The connection to ws://localhost:8080/ was interrupted while the page was loading.

I’m quite sure that everything sent by the server is a json so I’m not sure what’s causing the problem. And I’m quite sure that the websocket is indeed running on 8080. I get a console output about a new connection when I send the request from Altair.

There is most likely something wrong on my side but I think Altair should give some more clear error. The JSON error as well as the console errors are quite confusing.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 18

Commits related to this issue

Most upvoted comments

Here is the error from console.

err is undefined logger.ts:37:35
    error logger.ts:37
    handleError error-handler.ts:15
    Angular 2
        next
        schedulerFn
    RxJS 5
        __tryOrUnsub
        next
        _next
        next
        next
    Angular 11
        emit
        onHandleError
        invoke
        run
        runOutsideAngular
        onHandleError
        handleError
        runTask
        invokeTask
        invokeTask
        globalZoneAwareCallback

It was caused by something on the server side. It was sending some wrong data back to the client. Can’t describe in more detail because I don’t fully understand it myself. I just some parts of code that didn’t make much sense and it started to work.