I have 2 processes on separate servers. One is running the Quartz scheduler and I want to connect to it from the other to manage triggers.
On the scheduler server the config is:
org.quartz.scheduler.rmi.export = true
org.quartz.scheduler.rmi.createRegistry = always
org.quartz.scheduler.rmi.registryHost = localhost
org.quartz.scheduler.rmi.registryPort = 1099
org.quartz.scheduler.rmi.serverPort = 1100
On the remote server the config is:
org.quartz.scheduler.rmi.proxy = true
org.quartz.scheduler.rmi.registryHost = ip-172-16-5-11.eu-west-1.compute.internal
org.quartz.scheduler.rmi.registryPort = 1099
When I try and connect to the remote scheduler I get the following error in the log:
ERROR [2016-07-28 09:10:23,017] xxxx: Error communicating with remote scheduler.
! java.net.ConnectException: Connection refused
! ... 83 common frames omitted
! Causing: java.rmi.ConnectException: Connection refused to host: log-emea-1; nested exception is:
! java.net.ConnectException: Connection refused
Although this host is a host on our network I have no idea why it is being returned by the remote registry.
There are no connectivity issues. If I run tcpdump on the remote machine I can see it connecting to the scheduler. It's just that the scheduler is returning this invalid host:
09:19:02.047589 IP 172.16.5.11.1099 > 172.16.0.81.54065: Flags [P.], seq 19:235, ack 105, win 210, options [nop,nop,TS val 1231389006 ecr 562121102], length 216
E.....#.#..........Q.K.1}.Z... ......c.....
Ie.N!.I.Q....w..9.e2...V0.|...sr.$org.quartz.core.QuartzScheduler_Stub...........pxr..java.rmi.server.RemoteStub......e....pxr..java.rmi.server.RemoteObject.a...a3....pxpw3.
UnicastRef.
log-emea-1...L/8. .a.69.e2...V0.|....x
Where is the Quartz RMI registry getting this hostname from? There are no clues in the hosts file or DNS. It appears to be random.
You could start your scheduler with the following JVM-Flag
java -Djava.rmi.server.hostname=...
(see RMI-FAQ or Why does java rmi keep connecting to 127.0.1.1. When ip is 192.168.X.X?)
I tried the JVM flag but that made no difference however it did lead me to a solution. I set the property in code and that fixed the problem.
System.setProperty("java.rmi.server.hostname", "quartz");
Related
I'm trying to set up a RabbitMQ server (version 3.7.4, installed via homebrew on macOS 10.13.4) such that my colleagues can work with it via the internal network. We are using the official Java client (com.rabbitmq:amqp-client:5.2.0). Unfortunately, they only get a ConnectException with the message Connection refused:
java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at com.rabbitmq.client.impl.SocketFrameHandlerFactory.create(SocketFrameHandlerFactory.java:60)
at com.rabbitmq.client.impl.recovery.RecoveryAwareAMQConnectionFactory.newConnection(RecoveryAwareAMQConnectionFactory.java:62)
at com.rabbitmq.client.impl.recovery.AutorecoveringConnection.init(AutorecoveringConnection.java:134)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:997)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:956)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:914)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1068)
at my.own.private.RabbitMqConnector.connect(RabbitMqConnector.java:29)
We already set up another user account (not guest) which has admin privileges. With almost the same Java code I can connect locally (setting the host to localhost) but not if I use my IP address. According to the RabbitMQ docs, the RabbitMQ server binds to all network interfaces by default (otherwise I would have said that it's a problem with address binding). I disabled my firewall so that shouldn't be the problem.
Here's the respective code:
final ConnectionFactory connectionFactory = new ConnectionFactory();
connectionFactory.setUsername("username");
connectionFactory.setPassword("password");
connectionFactory.setHost("10.10.33.12");
connectionFactory.setPort(5672);
connectionFactory.setVirtualHost("/");
try (final Connection connection = connectionFactory.newConnection()) {
// doo stuff with the connection
}
I finally found the actual problem and it's not related to Java or how I configured the ConnectionFactory. It was indeed a problem how the RabbitMQ package for homebrew is configured. In the rabbitmq-env.conf file, there was the following setting
NODE_IP_ADDRESS=127.0.0.1
This setting caused RabbitMQ to only listen on 127.0.0.1 for incoming connections. Once I removed the setting and restarted the service, I could connect from other machines as well.
Thank you all for your help!
The issue is not with your code. I would suggest you to check such things:
RabbitMQ Server is up and running
Your custom user can access virtual host "/"
Check firewall settings if any, probably it's refusing connection with remote host
One of these should be the cause, hope it helps!
Kindly, I have the mentioned error for this code when running on Wifi while it works when using phone 3G hotspot:
username='XXX#hotmail.com';
pass='XXXXX';
port='587'; % hotmail
props = java.lang.System.getProperties;
props.setProperty('mail.smtp.starttls.enable', 'true' );
props.setProperty('mail.smtp.auth','true');
props.setProperty('mail.smtp.socketFactory.port',port);
setpref('Internet','SMTP_Server','smtp.live.com');
setpref('Internet','E_mail',username);
setpref('Internet','SMTP_Username',username);
setpref('Internet','SMTP_Password',pass);
sendmail(username,'Available');
Error:
Error using sendmail (line 171)
Could not connect to SMTP host: smtp.live.com, port: 25;
Connection timed out: connect
Should I change anything in the router settings?
enter image description here
You might have port 25 blocked. Try this:
telnet smtp.live.com 25
and copy results here.
Port 25 is often blocked by ISP to prevent spamming.
If you use Windows OS, you may have telnet client switched off in your system, so you are not able to use it in your command window (cmd). Go to Control Panel -> Programs and Features -> Turn Windows Features on or off and check Telnet Client.
I am trying to run on the port number 5000, tcp://localhost:5000
it shows the following error
WARNING: Could not refresh JMS Connection for destination 'queue://jmsExample' - retrying in 5000 ms. Cause: Could not connect to broker URL: tcp://localhost:5000. Reason: java.net.ConnectException: Connection refused: connect
Any Help please
The port 5000 is already in use by another process or service
I have an EJB container that is deployed on JBoss 5.1 on to a Amazon AWS Fedora 8 virtual machine. I have another application which I want to access this EJB container remotely over the internet. But I am getting the following exception
javax.naming.CommunicationException [Root exception is java.rmi.ConnectException: Connection refused to host: xxx.xxx.xx.x; nested exception is: java.net.ConnectException: Connection timed out]
Caused by: java.rmi.ConnectException: Connection refused to host: xxx.xxx.xx.x; nested exception is: java.net.ConnectException: Connection timed out
Caused by: java.net.ConnectException: Connection timed out
Here xxx.xxx.xx.x is the internal IP of the machine running the EJB.
Here is the code I used to access it
Properties props = new Properties();
props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
props.setProperty(Context.INITIAL_CONTEXT_FACTORY,org.jboss.security.jndi.JndiLoginInitialContextFactory");
props.setProperty(Context.PROVIDER_URL, "<external-ip>:1099");
props.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
props.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
props.put("java.naming.provider.url", "jnp://<external-ip>:1099");
InitialContext ic = new InitialContext(props);
ic.lookup("EJBName");
I have also edited the /etc/hosts file like
127.0.0.1 localhost.localdomain localhost
xxx.xxx.xx.x hostname alias
and started JBoss with
-Djboss.bind.address=0.0.0.0 -Djava.rmi.server.hostname=xxx.xxx.xx.x -Dremoting.bind_by_host=false
I guess I have done all the necassary configurations and correct code for this but doesn't seems to work. Please help me solving this issue it has been bugging me for over a week now. And sorry for hiding the actual ips for security reasons.
Connection timeout It could be a firewall issue. Verify that the port is open: http://www.canyouseeme.org/
You can also try setting the properties: "org.omg.CORBA.ORBInitialHost" and "org.omg.CORBA.ORBInitialPort".
Can you telnet on: host address and orb port. i.e. 127.0.0.xxx 3700
If you do not get answer then it's definitely a firwall issue.
I want to be able to send messages to a remote JBoss server (JBoss MQ).
I can do it for a local one but i'm stuck when trying with a remote one.
can anyone explain to me how to do it ?
are there any specific steps to take ?
[what i've tried so far]
I need to send a message to a remote server's queue (running "JBoss MQ") so that it can process the message and act on it.
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
properties.put(Context.URL_PKG_PREFIXES, "org.jnp.interfaces");
properties.put(Context.PROVIDER_URL, "jnp://192.168.131.129:1299");
InitialContext jndiContext = new InitialContext(properties);
//[2] Look up connection factory and queue.
ConnectionFactory connectionFactory = (ConnectionFactory)jndiContext.lookup("UIL2XAConnectionFactory");
Queue queue = (Queue)jndiContext.lookup("Queue/DataTransferQueue");
but I get an exception when running the above code :
(even though, I can ping the remote server).
javax.naming.CommunicationException: Could not obtain connection to any of these urls: 192.168.1.131.129:1299 and
discovery failed with error: javax.naming.CommunicationException:
Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out]
[Root exception is javax.naming.CommunicationException: Failed to connect to server 192.168.1.131.129:1299
Is there anything special to do to connect to a remote queue ?
Have you verified that you can connect to that remote host and port, i.e. telnet 192.168.131.129 1299? You might have a firewall that's blocking some traffic but allowing pings.
OK, so after trying a lot, I finally found out what the problem was :
I didn't start JBoss on the remote server in a way it could accept remote connections. by default, JBoss starts allowing only local connections.
so, I restarted it with this argument : -b 0.0.0.0 and it works fine now.
Thanks for your help and support.