mongodb 从uMongo连接到EC2

xtfmy6hx  于 2023-03-17  发布在  Go
关注(0)|答案(2)|浏览(148)

I'm trying to remotely connect to MongoDB on an Amazon EC2 server using uMongo.
I've opened a port on my Amazon server:

  • Type: Custom TCP Rule
  • Protocol: TCP
  • Port Range: 27017
  • Source: 0.0.0.0/0.

I've added a connection in uMongo with the following settings:

  • Name: Porject Name
  • Servers: https://12.34.56.789:27017
  • Connection Mode: Automatic
  • Socket Type: Plain
  • Connect Timeout: 2,000
  • Socket Timeout: 0
  • Safe Writes: [checked]
  • Proxy Type: None
  • Proxy Host: localhost
  • Proxy Port: 9,000

All the other fields are empty. Basically, I only changed the "Servers" field and left all the others untouched.
Then, when I try to connect via this connection, I get the following exception:
java.lang.NumberFormatException: For input string: "//12.34.56.789" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at java.lang.Integer.parseInt(Integer.java:569) at java.lang.Integer.valueOf(Integer.java:766) at com.edgytech.umongo.MainMenu.connect(MainMenu.java:177) at com.edgytech.umongo.MainMenu.connect(MainMenu.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.edgytech.swingfast.ButtonBase.actionPerformed(ButtonBase.java:297) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259) at javax.swing.AbstractButton.doClick(AbstractButton.java:376) at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:833) at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:877) at java.awt.Component.processMouseEvent(Component.java:6533) at javax.swing.JComponent.processMouseEvent(JComponent.java:3324) at java.awt.Component.processEvent(Component.java:6298) at java.awt.Container.processEvent(Container.java:2236) at java.awt.Component.dispatchEventImpl(Component.java:4889) at java.awt.Container.dispatchEventImpl(Container.java:2294) at java.awt.Component.dispatchEvent(Component.java:4711) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466) at java.awt.Container.dispatchEventImpl(Container.java:2280) at java.awt.Window.dispatchEventImpl(Window.java:2746) at java.awt.Component.dispatchEvent(Component.java:4711) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758) at java.awt.EventQueue.access$500(EventQueue.java:97) at java.awt.EventQueue$3.run(EventQueue.java:709) at java.awt.EventQueue$3.run(EventQueue.java:703) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86) at java.awt.EventQueue$4.run(EventQueue.java:731) at java.awt.EventQueue$4.run(EventQueue.java:729) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76) at java.awt.EventQueue.dispatchEvent(EventQueue.java:728) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
What am I doing wrong?

xt0899hw

xt0899hw1#

当您遇到java.lang.NumberFormatException时,这意味着它无法识别数字格式。

`java.lang.NumberFormatException: For input string: "//12.34.56.789"

在这种情况下,服务器名称解析器会尽最大努力处理FQDN和IP地址。在这种情况下,解析器会剥离URL方案(http/https/ftp等),并假设您输入IP地址。它会调用尝试解析数字,但失败,因为前缀为”//"。
要解决此问题,请输入IP地址或不带url方案的完全限定域名(FQDN

0lvr5msh

0lvr5msh2#

基于这错误讯息,它看起来像你已经配置了'connection'错误通过包括'https'在这主机字符串. try just '12.34.56.789:27017'代替并且象另一海报上面提到的,第一检查你甚至可以连接到这mongo主机使用某事象:

telnet 12.34.56.789 27017

如果您的EC2安全组设置错误,telnet命令将无限期地挂起,显示'Trying 12.34.56.78...'
高温加热

相关问题