Closed aprilahijriyan closed 1 week ago
@aprilahijriyan what client are you using to connect?
The issue here — I'm almost certain — is that the client you're using is not including a User-Agent
header on the initial HTTP request, which is hitting this (admittedly heavy-handed) "spam" heuristic in the public https://httpbingo instance and getting rejected with the 402 Payment Required response:
case ua == "":
// https://github.com/mccutchen/httpbingo.org/issues/5
//
// this is more aggressive than strictly necessary for that particular
// traffic pattern, but it seems reasonable to me to reject all traffic
// that doesn't include at least *some* User-Agent identifier
return true
As noted in https://github.com/mccutchen/httpbingo.org/issues/5, this was added to protect that public instance from some abusive traffic.
I'll push up a tweak to that heuristic to allow empty user agents for badly behaved websocket clients (I see from local testing that websocat — a fairly prominent CLI client — also fails to send a User-Agent header, so maybe this is a common problem.
Fix was committed in https://github.com/mccutchen/httpbingo.org/commit/eb8d654bf54dd2b2da7a224304cf01af2f0aed3e and deployed to https://httpbingo.org. Please let me know if it works for you (and please do let me know what websocket client you're using)!
Testing with websocat
, which also failed with an HTTP 402 error, now works as expected:
$ websocat wss://httpbingo.org/websocket/echo
hello
hello
world
world
@mccutchen Thanks for response.
It seems like the main problem is with the API client I'm using. I'm using Postman.
I am currently creating an API Gateway project. I am using your project as a test case. I am running your project on my local server using Docker.
I am running your project on my local server using Docker.
Are you sure you're running "plain" go-httpbin on your local server? There's no code anywhere in go-httpbin that would cause it to respond with the 402 Payment Required response to the initial websocket HTTP request, but there was code that would respond this way in https://github.com/mccutchen/httpbingo.org until the fix mentioned above.
If you're still having this problem, I'd be happy to help debug further if you can write down the steps to reproduce!
I am using the docker image from https://hub.docker.com/r/mccutchen/go-httpbin (Is this yours?)
The error above is no longer there if I test it again with httpbingo.org.
I think there's been some confusion here:
In the screenshot in the original report above, I see ws://httpbingo.org/websocket/echo
, which indicates that you were testing with the public instance available at https://httpbingo.org, and that public instance WOULD respond with the reported 402 Payment Required error if Postman is not sending a User-Agent header along with the request. That was fixed in https://github.com/mccutchen/httpbingo.org/commit/eb8d654bf54dd2b2da7a224304cf01af2f0aed3e
In a follow up, you say "I am running your project on my local server using Docker" and indicate that you mean the published docker image (https://hub.docker.com/r/mccutchen/go-httpbin), but running that docker image locally would NOT respond with a 402 Payment Required error, because it contains no code that could have responded like that.
From my end, I am confident that this has been resolved.
Thanks again for the report, and please let me know if you're still having issues!
is there something wrong?