benbjohnson / melomel

External ActionScript Interface.
https://github.com/benbjohnson/melomel/wiki
Other
42 stars 8 forks source link

Can only connect, if I execute Melomel.connect() twice #29

Closed scho closed 13 years ago

scho commented 13 years ago

Hi,

I'm using Flex together with RoR on a Ubuntu system. Now that I wanted to integrate melomel (gem: 0.6.2, swc: 0.6.8) + cucumber (1.0.2) I ran into the following issue:

My env.rb looks like this:

Before do |scenario| @driver = Selenium::WebDriver.for :firefox @driver.navigate.to "http://localhost:3000/" Melomel.connect() end

If I start cucumber, I always get a sandbox violation error in Flex. It seems like the socket on port 10101 never gets connected. (Inserted some puts into melomel/bridge.rb)

But then, if go into the rails concole (or irb) and I execute Melomel.connect() everything will work perfectly, as far as I can see that. I can start cucumber, my Flex app connects, gets the policy-file and tests are running. A strange thing is, that the second Socket, which I've started via cucumber, handles everything. The first one doesn't do anything.

Well, thanks in advance for taking a look at this. Besides that issue, melomel looks really promissing!

benbjohnson commented 13 years ago

What is your OS?

scho commented 13 years ago

I use Ubuntu 10.04.

benbjohnson commented 13 years ago

Oh, sorry. You mentioned Ubuntu above. I haven't done any testing on Linux. Only Mac OS X & Windows. There were some intermittent connection issues found on Windows because of the retry settings in Melomel but those have been fixed in v0.6.6.

If you have access to a Mac or Windows machine, can you try it on there?

scho commented 13 years ago

Yes, I can try it on a Windows machine, but not before Monday.

scho commented 13 years ago

Sorry, I couldn't test it on a windows machine, but I think I found the reason for my problem. The first Melomel.connect binds to the IPV6 address ::1 and the second one to the IPV4 address 127.0.0.1

netstat shows the following:

Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:10101 0.0.0.0:* LISTEN 3479/ruby tcp6 0 0 ::1:10101 :::* LISTEN 3397/ruby

benbjohnson commented 13 years ago

Does anything need to be changed in the code? Or should I close this one out?

scho commented 13 years ago

Mmmh, it works if I connect before, but that's pretty ugly. Isn't it possible to tell the socket to use the IPV4 address instead of the IPV6?

benbjohnson commented 13 years ago

Try connecting like this:

Melomel.connect('127.0.0.1')

That should force an IPV4 connection. If that works for you then I'll change the default in the Ruby library.

scho commented 13 years ago

Hi, sorry for the late reply, but I've been on holiday. Good news: It works with

Melomel.connect('127.0.0.1')

so you can change the default value in the ruby library. Thanks for fixing this!

benbjohnson commented 13 years ago

I fixed it and released a new version of the Ruby library (v0.6.3):

https://github.com/benbjohnson/melomel.rb

Let me know if you have any other issues. Thanks!