We're Hiring!

Java APIs: cannot connect to server on virtual machine

General and open developer discussion about using OMERO APIs from C++, Java, Python, Matlab and more! Please new questions at https://forum.image.sc/tags/omero
Please note:
Historical discussions about OMERO. Please look for and ask new questions at https://forum.image.sc/tags/omero

If you are having trouble with custom code, please provide a link to a public repository, ideally GitHub.

Java APIs: cannot connect to server on virtual machine

Postby Alex_V » Wed Jul 06, 2016 9:24 am

Hi there,
I'm considering deploying an OMERO server and use JAVA APIs in a program that I already wrote to access it. To test if this solution will answer my needs and to get the basics I installed the OMERO 5.2.4/ICE 3.5 server on a virtual machine running Ubuntu 14.04 LTS.
I managed to install the server and deploy OMERO.web and everything is working perfectly: I can connect through OMERO.web from both the guest and the host (by the way, the walkthrough is very well done considering that I've never worked before with linux and this was the first server I installed ;) ). Then to play a bit with the Java APIs I wrote a little project in ECLIPSE that would connect to the server and display the number of projects owned by the omero_user. When I run it in the virtual machine everything works fine problems arise when I try to run it from the host OS (Windows 10). I think that the problem is related to the server hostname as port, usermame and password would be the same. So far, what I tried was to get the IP of the virtual machine, assign it a name in the ../drivers/etc/hosts file and then use this name as the server hostname. This is obviously not working, any suggestion?
Alex_V
 
Posts: 4
Joined: Wed Jul 06, 2016 8:17 am

Re: Java APIs: cannot connect to server on virtual machine

Postby Dominik » Thu Jul 07, 2016 8:55 am

Hi Alex,

what do you use for running the virtual machine, is it VirtualBox? My first guess would be that there are some OMERO specific ports blocked for the virtual machine.
By the way, there's actually no need for assigning a name, you can use the IP directly as hostname. We should probably make that a bit clearer in the API documentation.

Regards,
Dominik
User avatar
Dominik
Team Member
 
Posts: 149
Joined: Mon Feb 10, 2014 11:26 am

Re: Java APIs: cannot connect to server on virtual machine

Postby Alex_V » Thu Jul 07, 2016 12:24 pm

Hi Dominik,
I've actually already tried to feed the IP but the result is the same :(
To give you more info:
I'm running virtualbox with network set to NAT and in the advanced tab I assigned the rules for port forwarding as described for the OMERO virtual appliance (only difference is that the guest IP is 10.0.3.15). Doing some research on the net I've seen that you can check if something is listening to the ports with the command: netstat -ntlp | grep LISTEN
What I get for this ports is:

tcp6 0 0 :::80 :::* LISTEN 1644/apache2
tcp6 0 0 :::4063 :::* LISTEN 3080/glacier2router
tcp6 0 0 :::4064 :::* LISTEN 3080/glacier2router

but unfortunately given my limited knowledge this does not tell me anything :(
Any idea?
Alex_V
 
Posts: 4
Joined: Wed Jul 06, 2016 8:17 am

Re: Java APIs: cannot connect to server on virtual machine

Postby Dominik » Thu Jul 07, 2016 1:15 pm

That's good, it means the OMERO.server is running and listening on these ports. I wonder if you can access these ports from your Windows machine. Can you enable the telnet client on you Windows machine?
Unfortunately I only found a description for Windows 7, but I guess for 10 it will be similar (it's an optional Windows Feature): https://social.technet.microsoft.com/wi ... lient.aspx

Then open a command line terminal and run 'telnet', this will give you a telnet prompt. Then try to connect to the OMERO.server port with 'open [IP address] 4064'. The connection should be established and you see "Press any key to continue", and after a few seconds the connection will be closed again. If the connection can't be established, you should get a "Connect failed" (or something similar) right away.

Regards,
Dominik
User avatar
Dominik
Team Member
 
Posts: 149
Joined: Mon Feb 10, 2014 11:26 am

Re: Java APIs: cannot connect to server on virtual machine

Postby Dominik » Thu Jul 07, 2016 1:23 pm

I just realized, if you set up the port forwarding according to the "OMERO virtual appliance" page, you have to use "localhost" (or "127.0.0.1") as hostname to connect to the server. Could you try that?

Regards,
Dominik
User avatar
Dominik
Team Member
 
Posts: 149
Joined: Mon Feb 10, 2014 11:26 am

Re: Java APIs: cannot connect to server on virtual machine

Postby Alex_V » Thu Jul 07, 2016 2:02 pm

Hi Dominik,
I tried all you suggested and here are the results:
using "localhost" or "127.0.0.1" in the Eclipse project does not work, actually this does not work neither when I try to connect to OMERO.web through firefox on the host.
The telnet client is giving me a "failed connection" error.
To test whether the problem could arise from the ports on the host machine being closed I added some rules on my firewall to explicitly open them but did not work. I even tried to disable the firewall entirely but it did not work :(
To continue investigate this in the windows cmd I typed: "netstat -an" and got:

TCP 127.0.0.1:2222 0.0.0.0:0 LISTENING
TCP 127.0.0.1:4063 0.0.0.0:0 LISTENING
TCP 127.0.0.1:4064 0.0.0.0:0 LISTENING
TCP 127.0.0.1:8080 0.0.0.0:0 LISTENING

doesn't this mean that the host is listening on these ports?
Alex_V
 
Posts: 4
Joined: Wed Jul 06, 2016 8:17 am

Re: Java APIs: cannot connect to server on virtual machine

Postby Dominik » Fri Jul 08, 2016 9:40 am

Hi Alex,

everything looks fine, I'm running a bit out of ideas...

I think I mixed things up with respect to virtual machine IP and localhost. Could you test again, with using localhost/127.0.0.1 only. Your portforwarding looks fine, so you should be able to use localhost/127.0.0.1 as hostname throughout.

1) OMERO.web on localhost, that should be the address: "http://localhost:8080"
2) telnet localhost: "open 127.0.0.1 4064"

I tried that locally on my machine (only OSX instead of Windows) using the pre-build OMERO virtual appliance, no problems. As last resort, could you test that? Download, import and run the VM from http://downloads.openmicroscopy.org/ome ... nce/5.2.1/ and try to connect to that virtual machine. It's a bit outdated (5.2.1), because we stopped building the VM for newer versions. But it would be interesting if that works for you.

Regards,
Dominik
User avatar
Dominik
Team Member
 
Posts: 149
Joined: Mon Feb 10, 2014 11:26 am

Re: Java APIs: cannot connect to server on virtual machine

Postby Alex_V » Fri Jul 08, 2016 2:01 pm

Hi Dominik,
as you suggested I downloaded the virtual appliance and did some test:
localhost:8080 in the host's web browser correctly redirects to OMERO.web
OMERO.insight with hostname:localhost works
Eclipse project with Java APIs works
This clearly indicates that I did something wrong when I deployed the server in my virtual machine :(
Thanks a lot for your help, keep up the good work :D
Alex
Alex_V
 
Posts: 4
Joined: Wed Jul 06, 2016 8:17 am

Re: Java APIs: cannot connect to server on virtual machine

Postby Dominik » Fri Jul 08, 2016 2:45 pm

You're welcome. I still wonder why it doesn't work with your VM, what's the difference to the prebuilt 5.2.1 one. For some reason your VM seems to block the OMERO ports (4063, 4064), although netstat claims the server is listening on these ports. In case you find out, please let me know!
Regards,
Dominik
User avatar
Dominik
Team Member
 
Posts: 149
Joined: Mon Feb 10, 2014 11:26 am


Return to Developer Discussion

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

cron