[newbie]I need a example(python), how to send a message to a rabbitmq in another PC. Just localhost works.

1,737 views
Skip to first unread message

Franklin Magalhães

unread,
Oct 6, 2019, 12:03:11 AM10/6/19
to rabbitmq-users
In tutorial there is no help to remote comunication>>>"In case you use a different host, port or credentials, connections settings would require adjusting."

There is a tutorial for this?

星沉

unread,
Oct 6, 2019, 2:40:53 AM10/6/19
to rabbitm...@googlegroups.com
On 2019/10/6 12:03 下午, Franklin Magalhães wrote:
> In tutorial there is no help to remote comunication>>>"In case you use a
> different host, port or credentials, connections settings would require
> adjusting."

import pika

connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))

Giving the case you are using pika library, You could replace
'localhost' with any host name or IP addr here.


regards.

Franklin Magalhães

unread,
Oct 6, 2019, 7:36:39 AM10/6/19
to rabbitmq-users
when i do this: that error returns

 File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py", line 359, in __init__
    self._impl = self._create_connection(parameters, _impl_class)
  File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py", line 450, in _create_connection
    raise self._reap_last_connection_workflow_error(error)
pika.exceptions.ProbableAuthenticationError: ConnectionClosedByBroker: (403) 'ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN. For details see the broker logfile.

iwe...@mail.de

unread,
Oct 6, 2019, 9:24:05 AM10/6/19
to rabbitm...@googlegroups.com
Hi

You should provide username and password to access the service since rabbitmq use password for vhost authentication.

Regards,
Wesley Peng

> --
> You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
> To view this discussion on the web, visit https://groups.google.com/d/msgid/rabbitmq-users/4bbffc61-1001-455d-a6c1-66ffdb2d419a%40googlegroups.com.
>

Franklin Magalhães

unread,
Oct 6, 2019, 9:49:36 AM10/6/19
to rabbitmq-users
Hi, i am using this code, but still dont work

#!/usr/bin/env python
import pika

credentials = pika.PlainCredentials(username='user', password='pass')
connection =  pika.BlockingConnection(pika.ConnectionParameters(host='192.168.0.10',
                                                      credentials=credentials))

channel = connection.channel()

channel.queue_declare(queue='hi', durable=True)

channel.basic_publish(exchange='', routing_key='hi', body='Test!')
print(" [x] Sent 'Test!'")
connection.close()






Em domingo, 6 de outubro de 2019 10:24:05 UTC-3, iwe...@mail.de escreveu:
Hi

You should provide username and password to access the service since rabbitmq use password for vhost authentication.

Regards,
Wesley Peng

> Am Oct 6, 2019 - 7:37 PM schrieb frank...@gmail.com:
>
>
> when i do this: that error returns
>
>  File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py", line 359, in __init__
>     self._impl = self._create_connection(parameters, _impl_class)
>   File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py", line 450, in _create_connection
>     raise self._reap_last_connection_workflow_error(error)
> pika.exceptions.ProbableAuthenticationError: ConnectionClosedByBroker: (403) 'ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN. For details see the broker logfile.
>
> Em domingo, 6 de outubro de 2019 03:40:53 UTC-3, 星沉 escreveu:
> On 2019/10/6 12:03 下午, Franklin Magalhães wrote:
> > In tutorial there is no help to remote comunication>>>"In case you use a
> > different host, port or credentials, connections settings would require
> > adjusting."
>
> import pika
>
> connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))
>
> Giving the case you are using pika library, You could replace
> 'localhost' with any host name or IP addr here.
>
>
> regards.
>
> --
> You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.

> To unsubscribe from this group and stop receiving emails from it, send an email to rabbitm...@googlegroups.com.

iwe...@mail.de

unread,
Oct 6, 2019, 10:17:51 AM10/6/19
to rabbitm...@googlegroups.com
That version is very old, you could upgrade to newest version. And once you assign the correct read/write privileges to the vhost then use correct credits to access the vhost, you would get things done.

Regards,
Wesley Peng

> Am Oct 6, 2019 - 10:13 PM schrieb frankl...@gmail.com:
>
>
> i am in a LAN, server is in 192.168.0.10 and other machine in 192.168.0.21
> guest is thedeafult vhost? i login by "user" username, that is the vhost 
> Version: RabbitMQ 3.6.10
>
> when i execute the code on server machine everything works
> but when i am try to send the message from ip 192.168.0.21 to 192.168.0.10 (server)
>
> Em dom, 6 de out de 2019 às 11:01, <iwe...@mail.de> escreveu:
> Hi
>
> Did you connect to the correct host and port? Do you access to default vhost? What’s rabbitmq version?
>
> Regards,
> Wesley Peng
>
> > Am Oct 6, 2019 - 9:56 PM schrieb frankl...@gmail.com:
> >
> >
> > Traceback (most recent call last):
> >   File "seVM.py", line 6, in <module>
> >     pika.ConnectionParameters(host='192.168.0.10', credentials = credentials))


> >   File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py", line 359, in __init__
> >     self._impl = self._create_connection(parameters, _impl_class)
> >   File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py", line 450, in _create_connection
> >     raise self._reap_last_connection_workflow_error(error)

> > pika.exceptions.AMQPConnectionError
> >
> > Em dom, 6 de out de 2019 às 10:51, <iwe...@mail.de> escreveu:
> > What’s the error message then?

> > > To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
> > > To view this discussion on the web, visit https://groups.google.com/d/msgid/rabbitmq-users/24a3b8d4-7098-484d-878c-a65fce00c7d8%40googlegroups.com.
> > >
> >
> >
> > --
> > Franklin Magalhães
> >
> > "Caia sete vezes, levante-se oito"
> >
>
>
> --
> Franklin Magalhães
>
> "Caia sete vezes, levante-se oito"
>

Franklin Magalhães

unread,
Oct 6, 2019, 4:03:10 PM10/6/19
to rabbitm...@googlegroups.com
i installed most recent version 3.8, but still not working, same error

Regards, Franklin

iwe...@mail.de

unread,
Oct 6, 2019, 9:11:57 PM10/6/19
to rabbitm...@googlegroups.com
Hi

You should make sure:

1. Rabbitmq server is running there, ports can be detected by Telnet or netcat tools.
2. Rabbitmq, erlang, client library are the latest versions.
3. Network connection fine, no filter for rabbitmq ports.
4. You have granted correct privileges to vhost, and access vhost using correct credit.

If still fails, please provide both client logs and server logs, as well as the description of running environment.

Regards,
Wesley Peng

> To view this discussion on the web, visit https://groups.google.com/d/msgid/rabbitmq-users/CAMCY51A1S1tKxQ40NL_iBNLpsoqyPz_wm8dSwq8Fs_YzsMzjdA%40mail.gmail.com.
>

Michael Klishin

unread,
Oct 7, 2019, 10:18:00 AM10/7/19
to rabbitmq-users
And two guides that would help are [1] and [2] (even though it is unlikely to be a connectivity issue). Server logs
are critically important to inspect when troubleshooting just about anything [3].



> > > > >
> > > >
> > > >
> > > >
> > > >
> > > > --
> > > > You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
> > > > To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.

> > > >
> > >
> > >
> > > --
> > > Franklin Magalhães
> > >
> > > "Caia sete vezes, levante-se oito"
> > >
> >
> >
> > --
> > Franklin Magalhães
> >
> > "Caia sete vezes, levante-se oito"
> >
>
> --
> You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.

>
>
> --
> Franklin Magalhães
>
> "Caia sete vezes, levante-se oito"
>
> --
> You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.

>

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.


--
MK

Staff Software Engineer, Pivotal/RabbitMQ
Reply all
Reply to author
Forward
0 new messages