videlalvaro / mypeb

PHP Erlang Bridge
BSD 3-Clause "New" or "Revised" License
26 stars 10 forks source link

peb_connect fails #4

Open jordillonch opened 11 years ago

jordillonch commented 11 years ago

After start an erlang node, peb_connect fails first time I run my script. If I try again it works. You can try this code: https://gist.github.com/videlalvaro/324043

I have last peb version from github, PHP 5.4.12 and Erlang R16B (erts-5.10.1) on Mac.

videlalvaro commented 11 years ago

Any logs or errors reported on either side?

videlalvaro commented 11 years ago

The problem seems to be in the timeout argument passed to the peb_connect function here: https://gist.github.com/videlalvaro/324043#file-ets-php-L98

If you don't provide any timeout value the code works.

Perhaps the meaning of the timeout value changed, from seconds to milliseconds. If yes I'd have to investigate.

marcosQuesada commented 11 years ago

As you say @videlalvaro , if no timeout is provided the code works, but is not fully my case, I've an strange issue where peb_rpc("ets", "new", $x, $this->link) returns the expected ets name, but when i query about it as ets:info i get undefined response.

After talk with @jordillonch , he told me that it can be related with timeout values, so i've been trying to use peb_connect passing high timeout values (200) , with no success, getting "violacion de segmento" , without any other errors , the main diference with @jordillonch encironment is that my system is running on ubuntu 12.10 . In fact, 'violacion de segmento' issue was the root case that force me to do not use timeout parameter under linux environments.

videlalvaro commented 11 years ago

As you know I haven't been using this library for a while.

It's basically a wrapper over this library http://erlang.org/doc/man/ei.html

It seems the timeout parameter now is in milliseconds: http://erlang.org/doc/man/ei_connect.html#ei_connect_tmo

If you want to debug it and submit a patch I'm happy to apply it.

I would suggest that if you want to debug this issue, create a simple gen_server where you log every handle_info call so you can see what messages are you getting

videlalvaro commented 11 years ago

Here you have another usage example of peb: https://github.com/tnc/rac in case you wanted to see more

marcosQuesada commented 11 years ago

Don't get me wrong @videlalvaro , i'm quite sure that maybe i'm doing something not propertly, Thank you about rac example, i've see that connection is created like: $this->link = peb_connect(RABBITMQ_HOST, RABBITMQ_COOKIE); So i understant that timeout is just an option.:)

videlalvaro commented 11 years ago

No worries @marcosQuesada in the code cited by @jordillonch about the ETS examples, the timeout is clearly wrong, because it's just 1 millisecond. I think the ei API changed that at some point