horizon icon indicating copy to clipboard operation
horizon copied to clipboard

request_id missing from handshake error responses

Open almstrand opened this issue 8 years ago • 1 comments

When a handshake request fails because of the following reasons, the response is missing the request_id:

  • Unauthenticated connections are not allowed
  • Anonymous connections are not allowed
  • Unknown handshake method XYZ

For example:

{
    "method": "anonymous",
    "request_id": 0
}

===>

{
    "request_id": null,
    "error": "Error: Anonymous connections are not allowed.",
    "error_code": 0
}

I'm tinkering with a Horizon client for Android. Without the request_id in the response, it makes it challenging to look up and invoke the listener method provided when the handshake request was made. It would be risky to assume the handshake request ID is always 0 as clients may re-try failed handshakes (with a new, non-expired token for example.)

Server version: 2.0.0 Client version: 2.0.0

almstrand avatar Sep 25 '16 06:09 almstrand

Did you add this in your server side as well as client side authType:anonymous or unauthenticated

const horizonServer = horizon([publicServer, loopbackServer], {
    project_name: 'myProjectName',
    auth: {       
      token_secret: 'foo-bar',
      allow_anonymous: true,//this is important
      allow_unauthenticated: true,//important
    },
});

vignestion avatar Oct 01 '16 04:10 vignestion