Omero.py connection issue

Hello,

I recently installed OMERO on a Ubuntu VM using this docker-compose file https://github.com/ome/docker-example-omero/blob/94a6a77d4efa98304ab8bcfb3e333343bd795603/docker-compose.yml.

The following was working properly:

  • connections from outside with omero web
  • connections from outside with omero.insight

(here outside means a Windows 10 x64 computer on the local network)

But then I realized that connecting from omero.py was not working. I had the same problem as described here Trouble connecting to omero server with Python

I tried to use OMERO CLI and I got the same result as @jsakkos, i.e. :

`WARNING:omero.client:..Ignoring error in client.__del__:<class 'Ice.SecurityException'> InternalException: 
Failed to connect: exception ::Ice::SecurityException {     
reason = SSL handshake failure: The parameter is incorrect. }`

So I used the same docker-compose project he suggested https://github.com/ome/docker-example-omero-websockets and I have now a functional ssl connection for the omero.web (which is nice!).

Now the following things are working :

  • connections with omero web (including ssl)
  • connections with omero.insight
  • connections with omero cli

But still, impossible to connect using omero.py. I tried both from the Ubuntu VM (server) and from my Windows computer. I have:

import omero.clients
from omero.gateway import BlitzGateway

conn = BlitzGateway('root', 'omero', host='localhost', port=4064)
conn.connect()
---------------------------------------------------------------------------
ConnectionRefusedException                Traceback (most recent call last)
<ipython-input-1-0d611f53a321> in <module>
      3 
      4 conn = BlitzGateway('root', 'omero', host='localhost', port=4064)
----> 5 conn.connect()

~/anaconda3/envs/omero/lib/python3.8/site-packages/omero/gateway/__init__.py in connect(self, sUuid)
   2227                 try:
   2228                     logger.debug("Creating Session...")
-> 2229                     self._createSession()
   2230                     logger.debug("Session created")
   2231                 except omero.SecurityViolation:

~/anaconda3/envs/omero/lib/python3.8/site-packages/omero/gateway/__init__.py in _createSession(self)
   2098             # the group
   2099             self.c.sf.getAdminService().getEventContext()
-> 2100         self.setSecure(self.secure)
   2101         self.c.sf.detachOnDestroy()
   2102         self.SERVICE_OPTS = self.createServiceOptsDict()

~/anaconda3/envs/omero/lib/python3.8/site-packages/omero/gateway/__init__.py in setSecure(self, secure)
   2066         if hasattr(self.c, 'createClient') and (secure ^ self.c.isSecure()):
   2067             oldC = self.c
-> 2068             self.c = oldC.createClient(secure=secure)
   2069             oldC.__del__()  # only needs to be called if previous doesn't throw
   2070             self._createProxies()

~/anaconda3/envs/omero/lib/python3.8/site-packages/omero/clients.py in createClient(self, secure)
    441         nClient.__insecure = not secure
    442         nClient.setAgent("%s;secure=%s" % (self.__agent, secure))
--> 443         nClient.joinSession(self.getSessionId())
    444         return nClient
    445 

~/anaconda3/envs/omero/lib/python3.8/site-packages/omero/clients.py in joinSession(self, session)
    591         and password to rejoin a running session
    592         """
--> 593         return self.createSession(session, session)
    594 
    595     def createSession(self, username=None, password=None):

~/anaconda3/envs/omero/lib/python3.8/site-packages/omero/clients.py in createSession(self, username, password)
    651                         ctx[omero.constants.IP] = self.__ip
    652                     rtr = self.getRouter(self.__ic)
--> 653                     prx = rtr.createSession(username, password, ctx)
    654 
    655                     # Create the adapter

~/anaconda3/envs/omero/lib/python3.8/site-packages/Glacier2_Router_ice.py in createSession(self, userId, password, _ctx)
    256         """
    257         def createSession(self, userId, password, _ctx=None):
--> 258             return _M_Glacier2.Router._op_createSession.invoke(self, ((userId, password), _ctx))
    259 
    260         """

ConnectionRefusedException: Ice.ConnectionRefusedException:
Connection refused

Could someone help me?

Can you try changing host='localhost' to the address of your OMERO server, either it’s DNS address or it IP?

My bad,

I was just missing the secure flag :laughing:

conn = BlitzGateway('root', 'omero', host='localhost', port=4064, secure=True)

@manics this example was from the Ubuntu vm itself, when I try from outside I use the IP address.

So now it works ! But only encrypted.

I guess the encrypted connection is slower, is it possible to configure OMERO to allow using both ?

Or if not possible, what should I change here: https://github.com/ome/docker-example-omero-websockets/blob/44186beaaf8e3d5cc4a6d5fc8fa23391dbc98c02/docker-compose.yml to use the non encrypted version ?

Thanks in advance

I think you can change this line


to ssl,tcp,wss to add unencrypted TCP connections.

If you do some benchmarking on encrypted vs unencrypyted connections could you share your results, as this will help us decide whether defaulting to fully encrypted connections in the future is a good idea or not. Thanks!

1 Like