java - Send message to remote server with RabbitMQ -
i've been running issue lately. i'm trying send packets remote server using rabbitmq , java quite time , need help. here code looks
connectionfactory factory = new connectionfactory(); //factory.sethost("localhost"); factory.setusername("dev"); factory.setpassword("/*user password*/"); factory.setvirtualhost("/"); //not sure means factory.sethost("/*remote server ip*/"); //is correct factory.setport(5672); connection = factory.newconnection();
i using windows server 2012, i've added rules firewall allow both udp & tcp on ports 5672 , 15672 inbound connections. these ports outgoing? assume i'd have allow on these ports on desktop well. know packets send , work locally, tested plenty of times. can't remote connection work without timing out. i'd love help!
i think right create connection did configure broker sever (rabbitmq)?
if not, @ beginning, default user name of broker server guest , password guest.
but problem is, guest user prohibited connecting broker remotely. can connect on localhost.
please configure server adding new:
- user
- password
- vhost[virtual hosts provide logical grouping , separation of resources].
or
to allow guest user connect remote host, should set loopback_users configuration item []. complete config code like:
[{rabbit, [{loopback_users, []}]}].
for sake of better understand , clarify question's answer, explained briefly.
- username : rabbitmq server login user name
- password : login password
- virtualhost : created virtualhost name. default vhost "/"
- hostname : host server name(where rabbitmq broker located) or ip address.
- hostportnumber : host server port number
you can alternatively use uris create connection:
connectionfactory factory = new connectionfactory(); factory. seturi("amqp://username:password@hostname:portnumber/virtualhost"); connection conn = factory.newconnection();
i hope worked fine. if have query against answer, pleas let me comments bellow.
Comments
Post a Comment