Giter Club home page Giter Club logo

Comments (4)

ujwal-setlur avatar ujwal-setlur commented on August 28, 2024

It seems this is an issue when I bounce the websocket link from the client side after I get a new login token and attempt to reconnect with the new token. If I don't send the authorization token at all, then the connection is made, though of course, I have an undefined user at the server side.

from apollo.

ujwal-setlur avatar ujwal-setlur commented on August 28, 2024

very interesting...if I send a token at all, I never get connected. If I send an empty token, websocket gets connected:

this code causes websocket to not connect:

  const wsLink = new WebSocketLink({
    uri: constants.GRAPHQL_SUBSCRIPTION_ENDPOINT,
    options: {
      reconnect: true,
      connectionParams: () => ( // a promise that resolves to return the loginToken
      new Promise((resolve, reject) => { // eslint-disable-line no-undef,no-unused-vars
        getLoginToken().then(token => {
          if (token) {
            console.log("wsLink loginToken = " + token);
            resolve({
              [constants.AUTH_TOKEN_KEY]: token // if I set a token here, connection does not work!
            });
          } else {
            resolve({
              [constants.AUTH_TOKEN_KEY]: ""
            });
          }
        }).catch(() => {
          console.log("could not retrieve a login token!");
        });
      }))
    }
  });

Using an empty token gets the connection to go through:

  const wsLink = new WebSocketLink({
    uri: constants.GRAPHQL_SUBSCRIPTION_ENDPOINT,
    options: {
      reconnect: true,
      connectionParams: () => ( // a promise that resolves to return the loginToken
      new Promise((resolve, reject) => { // eslint-disable-line no-undef,no-unused-vars
        getLoginToken().then(token => {
          if (token) {
            console.log("wsLink loginToken = " + token);
            resolve({
              [constants.AUTH_TOKEN_KEY]: "" // using an empty token gets it go through
            });
          } else {
            resolve({
              [constants.AUTH_TOKEN_KEY]: ""
            });
          }
        }).catch(() => {
          console.log("could not retrieve a login token!");
        });
      }))
    }
  });

from apollo.

ujwal-setlur avatar ujwal-setlur commented on August 28, 2024

This is almost certainly a server side issue, particularly with the meteor integration. If I set a header of "boo" instead of "meteor-login-token", the the connection goes through as well:

  const wsLink = new WebSocketLink({
    uri: constants.GRAPHQL_SUBSCRIPTION_ENDPOINT,
    options: {
      reconnect: true,
      connectionParams: () => ( // a promise that resolves to return the loginToken
      new Promise((resolve, reject) => { // eslint-disable-line no-undef,no-unused-vars
        getLoginToken().then(token => {
          if (token) {
            console.log("wsLink loginToken = " + token);
            resolve({
              ["boo"]: token // header is boo instead of meteor-login-token
            });
          } else {
            resolve({
              [constants.AUTH_TOKEN_KEY]: ""
            });
          }
        }).catch(() => {
          console.log("could not retrieve a login token!");
        });
      }))
    }
  });

from apollo.

ujwal-setlur avatar ujwal-setlur commented on August 28, 2024

I can reproduce this using graph-ql playground by setting a "meteor-login-token" HTTP header and doing a subscription query:

{"meteor-login-token": "boo"}

I get this error in playground:

{
  "error": {
    "message": "Cannot read property 'userDefaultFields' of undefined"
  }
}

from apollo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.