net/http TLS handshake timeout when importing mongo driver golang - mongodb

Receiving net/http TLS handshake timeout error while importing the official mongo db driver for golang.
go get go.mongodb.org/mongo-driver/mongo
I get the following response
go: found go.mongodb.org/mongo-driver/mongo in go.mongodb.org/mongo-driver v1.3.3
go: downloading github.com/klauspost/compress v1.9.5
../pkg/mod/go.mongodb.org/mongo-driver#v1.3.3/x/mongo/driver/compression.go:16:2: github.com/klauspost/compress#v1.9.5: Get "https://storage.googleapis.com/proxy-golang-org-prod/6d1974c4504adb60-github.com:klauspost:compress-v1.9.5.zip?Expires=1589817362&GoogleAccessId=gcs-urlsigner-prod%40golang-modproxy.iam.gserviceaccount.com&Signature=srzNvLvGM%2BKbAJhtmgjaHE6IjyZLy5JZAQNIgN3oVQis5BEsetWpzu0uPqoxb0bqounoXFKV0COgkR0J%2FjcTenPcihBp0WiZua%2FrHvoLIGRRUgDxPJPs3gniTu2bxqf4aj4BfkTOTH9Hez9QKevGcVGSzkMsB9KsNMbcjnNN2uVJcgfUC4b29xZpEYhXt2mGXqMnU3jflnyRUkK9QDzPArOgbVjZp9bO0RQIs%2BMhiMt822NoZBhOdXCFhrtNie89SQJpELJAIC5r7P8pezU8pUJeQgugXfpgYBmtiH1H5Cvf9xh7v2Bfd3I96wSfUWkrCtceFfG5Xe6CSVmhPjFoeQ%3D%3D": net/http: TLS handshake timeout
I could import other golang libraries just fine. How can I solve this?

The error you're getting shows go get proxying through:
https://storage.googleapis.com/proxy-golang-org-prod/...
and that proxy connection is timing out.
So try disabling proxying. You can do this, temporarily, on a per-request basic like so:
GOPROXY="direct" go get go.mongodb.org/mongo-driver/mongo

This looks like a simple networking issue, as I performed the go get just fine on my machine just a minute ago. Give it a bit and try again.

Related

Error: queryTxt ESERVFAIL cluster0.b4oyxi0.mongodb.net

I am developing a MERN stack application. My Node web server used to work fine. Recently however, whenever I start my Node server, I get the following error:
[1] Error: queryTxt ESERVFAIL cluster0.b4oyxi0.mongodb.net
[0] [HPM] Error occurred while proxying request localhost:3000/api/users/login to http://localhost:5000/ [ECONNRESET] (https://nodejs.org/api/errors.html#errors_common_system_errors)
[1] [nodemon] app crashed - waiting for file changes before starting...
What does this error mean and how can I fix it?
Not exactly sure what the error means. I encountered a similar error and the non +srv connection string did it for me.
To get one,
head out to your Atlas Dashboard under Database Deployment,
click Connect,
then choose Connect your application.
On the Node.js driver version, lower that to 2.2.12 or later.
This should give the connection string.
It's a DNS server issue. Try changing your DNS server in your network settings to any of these, or any other trusted one you know:
208.67.222.222
1.1.1.1
8.8.8.8
9.9.9.9

Sending requests from Postman to Heroku returns 503 and/or UnknownReplWriteConcern

I am trying to send a post request from Postman to a Heroku app but it keeps returning a 503 status error with code = H12. The app works fine in localhost.
With regards to the database, I have a cluster (M0) in Atlas and I am using the same non-srv connection string that I am using to connect Compass to the same cluster in Atlas.
The only error I see when I run heroku logs is:
//single line broken into four lines for readability
UnhandledPromiseRejectionWarning:
MongooseServerSelectionError:
Could not connect to any servers in your MongoDB Atlas cluster.
One common reason is that you're trying to access the database from an IP that isn't whitelisted.
But I have already added 0.0.0.0/0 in Atlas's IP whitelist.
What could be causing this error?
So with the help and assistance of the MongoDB Atlas support team, I managed to fix this by simply using the srv version of the connection string that I got from Atlas to connect with Heroku. After switching the connection string to the srv version, postman was able to make requests without getting the 503 error.
The srv version looks something like this:
mongodb+srv://someClusterAdmin:somePassword#someCluster.vwieg.mongodb.net/someName?retryWrites=true&w=majority
However, MongoDB Compass (v1.21.2) can't seem to connect with the srv version connection string so I had to continue using the non-srv version for Compass which looks something like this:
mongodb://someClusterAdmin:somePassword#someCluster-shard-00-00.vwieg.mongodb.net:27017,someCluster-shard-00-01.vwieg.mongodb.net:27017,someCluster-shard-00-02.vwieg.mongodb.net:27017/someName?authSource=admin
One issue that I noticed with the current srv version connection string above (which might be happening just for me though so skip this step if the current srv version connection string works fine for you) was that even though it seems to be adding the data that I'm sending from postman to Atlas, I always get the following error:
"code": 79,
"codeName": "UnknownReplWriteConcern",
//some other lines
So with the advise of the MongoDB Atlas support team, I just remove w=majority from the connection string and that seems to fix that issue.
// &w=majority removed
mongodb+srv://someClusterAdmin:somePassword#someCluster.vwieg.mongodb.net/someName?retryWrites=true

Looking for debugging advice on SSL errors from EKS using varnish

I know this is somewhat specific of a question, but I'm having a problem I can't seem to track down. I have a single pod deployed to EKS - the pod contains a python app, and a varnish reverse caching proxy. I'm serving chunked json (that is, streaming lines of json, a la http://jsonlines.org/), and it can be multiple GB of data.
The first time I make a request, and it hits the python server, everything acts correctly. It takes (much) longer than the cached version, but the entire set of json lines is downloaded. However, now that it's cached in varnish, if I use curl, I get:
curl: (56) GnuTLS recv error (-110): The TLS connection was non-properly terminated.
or
curl: (56) GnuTLS recv error (-9): A TLS packet with unexpected length was received.
The SSL is terminated at the ELB, and when I use curl from the proxy container itself (using curl http://localhost?....), there is no problem.
The hard part of this is that the problem is somewhat intermittent.
If there is any advice in terms of clever varnishlog usage, or anything of the same ilk on AWS, I'd be much obliged.
Thanks!
Because TLS is terminated on your ELB loadbalancers, the connection between should be in plain HTTP.
The error is probably not coming from Varnish, because Varnish currently doesn't handle TLS natively. I'm not sure if varnishlog can give you better insights in what is actually happening.
Checklist
The only checklist I can give you is the following:
Make sure the certificate you're using is valid
Make sure you're connecting to your target group over HTTP, not HTTPS
If you enable the PROXY protocol on your ELB, make sure Varnish has a -a listener that listens for PROXY protocol requests, on top of regular HTTP requests.
Debugging
Perform top-down debugging:
Increase the verbosity of your cURL calls and try to get more information about the error
Try accessing the logs of your ELB and get more details there
Get more information from your EKS logs
And finally, perform a varnislog -g request -q "ReqUrl eq '/your-url'" to get a full Varnishlog for a specific URL

RESTHeart Bind Error to MongoDB on AmazonAWS

I am trying to assist a customer in getting RESTHeart up and connected to MongoDB that is hosted on AmazonAWS. The startup from the yml file looks like it is connecting to our MongoDB (yellow highlight in attachment) but then it fails with a bind error. Have tried setting the mongo-uri with and without port, IP and hostname all with the same result. I checked the softinstigate site for help or a forum and they suggest here. Any suggestions or guidance would be greatly appreciated.
Statup log with DEBUG on
The http and https are bound to the same address. This is not possible.
In the log I also spot
Mongodb version: ?
This is usually due to restheart not communicating with mongodb. You have to check your network settings...
Are you able to telnet to mongodb from the host running restheart?

TLS Socket connection through Nodejs

Im trying to establish a TLS socket connection to chat.facebook.com port:5222 through Nodejs.
Im using the following code :
var a=require('tls');
var b=a.connect(5222,'chat.facebook.com',function(){console.log("connected");});
b.on('error',function(error){console.log(error);})
But it is not getting connected and instead giving an error :
[Error: 140089045411648:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:../deps/openssl/openssl/ssl/s23_clnt.c:683:]
I have tried a similiar connection to encrypted.google.com:443 and console readily fired a "connected" .
Can someone guide me what i have been missing or what can be done to overcome this problem.
xmpp with tls uses "STARTTLS", a protocol upgrade from plaintext to encrypted. See http://xmpp.org/rfcs/rfc6120.html#tls for details.
(It means you have to send some unencrypted xml stuff first, and wait for the other end to confirm your choice to upgrade to TLS)