Oracle NoSQL is a database that should be hosted on Linux, so I have a virtual Ubuntu running in Oracle VM VirtualBox.
When you run the KvStore for Oracle NoSQL it uses port 5000 for the database, and 5001 for the admin console. From my pc, I can access the admin console running on the linux virtual machine like so:
http://192.168.0.25:5001/
Where 192.168.0.25 is the inet addr I get from the linux machine's ifconfig command.
However, if I try to connect to the database from java, passing java the host and port number like so:
KVStoreConfig kvconfig = new KVStoreConfig("kvstore", "192.168.0.25:5000");
I get the following error:
Exception in thread "main" oracle.kv.FaultException: Could not contact any RepNode at: [192.168.0.25:5000] (11.2.2.0.26)
Fault class name: oracle.kv.KVStoreException
at oracle.kv.KVStoreFactory.getStore(KVStoreFactory.java:123)
at nosql.Test.main(Test.java:18)
Caused by: oracle.kv.KVStoreException: Could not contact any RepNode at: [192.168.0.25:5000]
at oracle.kv.impl.util.TopologyLocator.getInitialTopology(TopologyLocator.java:226)
at oracle.kv.impl.util.TopologyLocator.get(TopologyLocator.java:85)
at oracle.kv.impl.api.RequestDispatcherImpl.<init>(RequestDispatcherImpl.java:285)
at oracle.kv.KVStoreFactory.getStore(KVStoreFactory.java:118)
... 1 more
Caused by: java.rmi.UnknownHostException: Unknown host: coraythan-VirtualBox; nested exception is:
java.net.UnknownHostException: coraythan-VirtualBox
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:616)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:128)
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:194)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:148)
at com.sun.proxy.$Proxy0.getSerialVersion(Unknown Source)
at oracle.kv.impl.util.registry.RemoteAPI.<init>(RemoteAPI.java:60)
at oracle.kv.impl.rep.admin.RepNodeAdminAPI.<init>(RepNodeAdminAPI.java:63)
at oracle.kv.impl.rep.admin.RepNodeAdminAPI.wrap(RepNodeAdminAPI.java:70)
at oracle.kv.impl.util.TopologyLocator.getInitialTopology(TopologyLocator.java:191)
... 4 more
Caused by: java.net.UnknownHostException: coraythan-VirtualBox
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:178)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
at java.net.Socket.connect(Socket.java:579)
at oracle.kv.impl.util.registry.ClientSocketFactory.createSocket(ClientSocketFactory.java:300)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)
... 14 more
I can get that to work fine when I host a KvStore on my normal computer and try to connect to it like that (using the normal computer's IP address) with java.
Another weird thing is that if I'm in the virtual machine, I can access the admin with this:
coraythan-virtualbox:5001
But if I try to do that from my main computer it gives me a "could not find" error.
I have tried changing my java connection to coraythan-virtualbox:5000, but that also doesn't work.
Does anyone know what I'm doing wrong here? Thanks!
The issue was that the linux computer did not automatically register its network name with my company's network. I had to have the network admin manually add a network name for the computer. The KVStore requires using the network name it seems.
You are making a socket using named address, that is DNS doesn't know such name. Try change it to IP address.
UnknownHostException
Thrown to indicate that the IP address of a host could not be
determined.
Related
I'm trying to connect two MacBooks using Java network programming, one is a server and the other is a client. In server, I wrote something like
ServerSocket s = new ServerSocket(8008);
and then in my client computer I wrote
hostname = "Alex";
Socket socket = new Socket(hostname, 8008);
where "Alex" is the computer name of my server, found in System Preference -> Sharing -> Computer Name, as shown in the screenshot. However when I run the script on client I got the following error message:
error: Alex
java.net.UnknownHostException: Alex
at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:564)
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327)
at java.base/java.net.Socket.connect(Socket.java:633)
at java.base/java.net.Socket.connect(Socket.java:583)
at java.base/java.net.Socket.<init>(Socket.java:507)
at java.base/java.net.Socket.<init>(Socket.java:287)
at EchoClient.main(EchoClient.java:9)
It seems that the hostname of my server is not recognized. Then where should I look up the hostname of my server computer?
Thanks!
If you are a Linux system,
add a record in /etc/hosts.
If you are a Windows system,
add a record in C:\windows\system32\drivers\etc\hosts
127.0.0.1 Alex
::1 Alex
I want to run my java application (i.e. Leshan Server) run Azure Linux VM. My VM is configured as dynamic IP. It is showing two IP addresses.
These are
virtual IP Address-1.1.1.1
0.0.0.0 (private IP)
these IP addresses are for example only.
My java application is using jetty server inside the code and I am passing the public from command window like this
java -jar leshan-server-demo-1.0.0-SNAPSHOT-jar-with-dependencies.jar -wh 0.0.0.0.
but it is throwing the exception
java.net.BindException: Cannot assign requested address
at sun.nio.ch.Net.bind0(Native Method) ~[?:1.8.0_141]
at sun.nio.ch.Net.bind(Net.java:433) ~[?:1.8.0_141]
at sun.nio.ch.Net.bind(Net.java:425) ~[?:1.8.0_141].
NOTE- It is running perfectly on local (private IP) and port is also open and not in use.
Is there other way to connect socket connection on azure or aws vms public IPs?
I'm trying to use JavaMail in order to connect to an IMAP Server (on a remote virtual linux machine - Ubuntu 14 LTS) but I'm getting the following exception:
java.net.ConnectException: Connection refused
I've already tried to establish the connection via Telnet and everything works.
The JavaMail version I'm using is 1.5.5 (also tested with 1.4.7) and I'm using the following properties:
Properties properties = System.getProperties();
properties.setProperty("mail.imap.host", SERVER);
properties.setProperty("mail.store.protocol", "imap");
properties.put("mail.imap.port", PORT);
Session session = Session.getInstance(properties, null);
Store store = session.getStore("imap");
store.connect(USERNAME, PASSWORD);
Notes:
It's working on my personal machine
It's working on another external machine
It's failing on the remote linux virtual machine
The IMAP server is on a different machine - which is accessible to all of the previous
I've done some research and some people told that it could be a firewall/blocking issue but how am I able to connect via Telnet?
Thanks.
Edited
The telnet command I've applied in the test-run:
telnet <server_ip> <port>
After this, the connection is successfuly established and I'm able to apply IMAP commands such as list status.
The output from javamail when it fails is the following:
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at java.net.Socket.connect(Socket.java:478)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:233)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
at com.sun.mail.iap.Protocol.<init>(Protocol.java:107)
at com.sun.mail.imap.protocol.IMAPProtocol.<init>(IMAPProtocol.java:104)
at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:538)
... 12 more
Firewalls usually work port based. This means telnet (23/TCP) can be allowed whereas IMAP (usually 143/993) is blocked.
You should check the firewall and check if the IMAP port is open.
Where is your program running? If you change getDefaultInstance to getInstance does it work?
I've found a solution!!
I performed a network capture on the remote machine and I saw that for some reason the javamail api was using the default IMAP folder and not the one I've selected..
Further tests revealed that changing the property value type to String instead of Integer solved this issue. It's important to notice that this didn't happen on other environments so I'm not sure the reason I had to make this change.
I am getting
Caused by: java.net.NoRouteToHostException: No route to host
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:564)
at sun.reflect.GeneratedMethodAccessor638.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.commons.httpclient.protocol.ReflectionSocketFactory.createSocket(ReflectionSocketFactory.java:140)
at org.apache.commons.httpclient.protocol.SSLProtocolSocketFactory.createSocket(SSLProtocolSocketFactory.java:130)
at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
javadoc says
Signals that an error occurred while attempting to connect a socket to
a remote address and port. Typically, the remote host cannot be
reached because of an intervening firewall, or if an intermediate
router is down.
Is this error on client side or remote side or it can be either of these?
Basically it says that your client cannot connect to the server due to the address is inaccessible from the client machine.
Please check that the address you are connecting to is accessible, either via ping command in your Command Prompt (Windows) or terminal (Unix-based):
ping <address>
or if it's a web server you can try to check it in your web browser.
The ping command is helpful for me in most cases, since I would know why exactly I can't connect to the address. It can be a mistyped address or like the javadoc suggests, problem with firewall.
Either. It could be a firewall on the client machine blocking outgoing calls or somewhere at the other end.
It may be possible the ping will provide responses, but the application may still fail to connect.
If that is the case, I would suggest using telnet to try and connect to the host using the desired port, telnet host.address port
If the connection is refused then the port on the host will need to be allowed. It that succeeds, but the application still won't connect:
Verify the address:port being used in your application are the same as those used in the telnet test.
It may be a local port on the client blocking the connection, in which case you would need to allow the port on the client
In my case it was solved like this:
1 - Clear the cache with 'yarn cache clean' or 'npm cache clean --force'
2 - after that reboot the pc.
If you clear the cache but do not reboot, the data will still be stored 'somewhere' on the network, so the port will not connect, it is still busy.
After restarting it connects smoothly.
I hope I was helpful!
I had the same issue, and resolve it by disabling the firewall on both sides :
systemctl disable firewalld
service firewalld stop
I had the same issue, I did run iptables flush on host server, this fixed the issue.
# iptables --flush
I am running a Java web application using tomcat to send generated reports via emails to the users.
I am able to send the emails but after few hours the server stops sending emails, with the following error.
javax.mail.MessagingException: Unknown SMTP host: mail.mydomain.co.uk;
nested exception is:
java.net.UnknownHostException: mail.mydomain.co.uk
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1970)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:642)
at javax.mail.Service.connect(Service.java:317)
at javax.mail.Service.connect(Service.java:176)
at javax.mail.Service.connect(Service.java:125)
at javax.mail.Transport.send0(Transport.java:194)
at javax.mail.Transport.send(Transport.java:124)
at com.turnkey.email.SendEmail.sendMail(SendEmail.java:119)
at com.turnkey.thread.CommunicationThread.run(CommunicationThread.java:399)
Caused by: java.net.UnknownHostException: mail.mydomain.co.uk
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:195)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at java.net.Socket.connect(Socket.java:478)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:319)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:233)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1938)
... 8 more
After some time the server starts sending emails again.
Can anyone tell me what could be the problem.
And how do I solve this problem?
Thanks
This looks like a failure in your name service. The JDK isn't able to look up the host name to find its internet address. Since this works sometimes and not others, it looks like an intermittent failure of the name service. The name service failure could be due to some failure in your local operating system, or it could be due to some network failure communicating with your DNS server or other name service server, or it could be a failure in that DNS server or name service server itself. Determining the exact cause of the failure will require some debugging. Note that the JDK caches the results of name server lookups for some time so you'll need to factor that into your debugging.
Also make sure there is no space at the end of smtp hostname eg. mail.google.comSPACEHERE . Surprisingly this happened to me and finally after removing this space there was no complain about smtp host . Email was successfully sent
Set for host the ip address of the domain name instead of the domain name.
use nslookup mail.mydomain.co.uk on cmd to find the ip address.
It worked for me.
Specially for AIX or Linux OS environment,
We need to add the hostname in the etc/hosts file.. to sole this.
Windows operating system , this may work on Windows system as there is no strict security check however AIX or Linux must add host name to etc/hosts file in order for ping the SMTP server.
avoid doing this may lead Unknown host issue