Can MATLAB connect to MongoDB over SSH tunnel?
5 views (last 30 days)
Show older comments
I'm having an issue with using the mongodb conncector over an ssh tunnel. MATLAB is trying to connect straight into the server without using the tunnel.
Because of security setup, I need to use an ssh connection to my mongo db. So, on a powershell I start with:
ssh -fNL 27017:localhost:27017 user@server
Then, in MATLAB I use:
connection=mongo('127.0.0.1',27017,'database','UserName','User')
or
connection=mongo('localhost',27017,'database','UserName','User')
Then, the error is:
Error using mongo (line 386)
[Mongo Driver Error]:Timed out after 10000 ms while waiting for a server that matches com.mongodb.client.internal.MongoClientDelegate$1@2da66a44. Client view of cluster state is {type=REPLICA_SET,
servers=[{address=server:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketException: server}, caused by {java.net.UnknownHostException: server}}].
Note that I have never told MATLAB about my server, so if its found on the error is because its retrieved through the tunnel on the first place.
I see two naive solutions:
- Code a class in matlab to set the ssh connection and the mongodb connection
- Start an ssh tunnel in matlab using java, then use the mongo connection already present in matlab.
Would those work?
Is there an actual way of making this work?
1 Comment
Answers (0)
See Also
Categories
Find more on Java Client Programming in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!