Docker Community Forums

Share and learn in the Docker community.

How to enabe the web socket connection in docker?

docker

(Giulio Braini) #1

I get the following error when I try to send some timeseries data:

edge@renedge:~/testcloud$ docker logs testcloud
Traceback (most recent call last):
  File "main.py", line 162, in <module>
    main(mock=debug)
  File "main.py", line 142, in main
    timeseries.send()
  File "/root/.local/lib/python2.7/site-packages/predix/data/timeseries.py", line 416, in send
    return self._send_to_timeseries(msg)
  File "/root/.local/lib/python2.7/site-packages/predix/data/timeseries.py", line 325, in _send_to_timeseries
    ws = self._get_websocket()
  File "/root/.local/lib/python2.7/site-packages/predix/data/timeseries.py", line 314, in _get_websocket
    self.ws = websocket.create_connection(url, header=headers)
  File "/root/.local/lib/python2.7/site-packages/websocket/_core.py", line 494, in create_connection
    websock.connect(url, **options)
  File "/root/.local/lib/python2.7/site-packages/websocket/_core.py", line 217, in connect
    options.pop('socket', None))
  File "/root/.local/lib/python2.7/site-packages/websocket/_http.py", line 113, in connect
    hostname, port, is_secure, proxy)
  File "/root/.local/lib/python2.7/site-packages/websocket/_http.py", line 154, in _get_addrinfo_list
    raise WebSocketAddressException(e)
websocket._exceptions.WebSocketAddressException: [Errno -3] Try again
edge@renedge:~/testcloud$  WebSocketAddressException(e)WebSocketAddressException: [Errno -3]

The same code works outside of the docker container! Here below you can find the content of my Dockerfile (I have hidden the proxy address):

FROM registry.gear.ge.com/predixmachine/alpine-x86_64

MAINTAINER Giulio Braini

# Install python packages
RUN apk add --update python py-pip python-dev
RUN apk add make automake gcc g++ subversion python3-dev
RUN pip install --upgrade pip
RUN pip install docker --user
RUN pip install predix==0.0.8 --user

# Set environmental variables
ENV HTTP_PROXY "http://XXX.XXX.XXX.XXX:80/"
ENV HTTPS_PROXY "http://XXX.XXX.XXX.XXX:80/"

COPY . /app
WORKDIR /app
CMD ["python", "main.py"]

What’s wrong?