Socket hang up on GET request with Auth header JWT
See original GitHub issueHey, i’m getting an error with a fairly simple GET request:
Error: { Error: socket hang up
at createHangUpError (_http_client.js:253:15)
at Socket.socketOnEnd (_http_client.js:345:23)
at emitNone (events.js:91:20)
at Socket.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickDomainCallback (internal/process/next_tick.js:122:9) code: 'ECONNRESET', response: undefined }
Any tips on how to resolve this? Do I need to config some socket things or something? I don’t understand if this is an issue with my code or perhaps some dependancy conflict. Everything i’ve tried doesn’t work 😦
Here is the test:
import superagent from 'superagent';
var request = superagent;
...
const USER_JWT_VALID = 'JWT asdf.....';
it('should work', (done) => {
request
.get('http://localhost:3000/api/something/private')
.set('Accept', 'application/json')
.set('Authorization', 'Bearer ' + USER_JWT_VALID)
.end((err, res) => {
console.log('Error: ', err);
if (err) done(err);
expect(res.body).to.be.an('object');
});
});
my related packages:
"express": "^4.14.0",
"superagent": "^3.3.1",
"mocha": "^3.2.0",
node v7.3.0.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Socket hang up on GET request with Auth header JWT #1145
Socket hang up means the server closed the connection, which could be caused either by a hard crash of the server or a...
Read more >Passport JWT auth in unit test - socket hang up - Stack Overflow
GET requests with the users's JWT in Authorization header work perfectly. It seems that the user being used for authentication, in the test ......
Read more >502 Bad Gateway - Socket hang up | Apigee Edge
The error code [socket hang up][ECONNRESET] indicates that the target server has closed the connection with Edge Microgateway. This can be searched in...
Read more >Socket hang up problems - Google Groups
Hi, I've been getting this issue every now and then on a long poll request. It doesn't happen consistently so I'm finding it...
Read more >Middlewares | Socket.IO
A middleware function is a function that gets executed for every incoming connection.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Socket hang up means the server closed the connection, which could be caused either by a hard crash of the server or a serious syntax error in the request.
So you see any errors on server side? Is it possible that you have some non-ASCII characters or unexpected newlines in your headers?
Try running
nc -l 3000
instead of your server and see what superagent sends.Sorry guys - this is nothing to do with superagent. This seems to be a bug with passport-jwt (auth GET requests are not getting past passport auth) Thanks all the same! 😃