我已经按照Predix Volcano App的模型创建了Predix Cloud应用程序。我可以从Windows笔记本电脑或Ubuntu虚拟机成功将时间序列发送到此类应用程序。为此,我使用PredixPy。数据时间序列摄取uri看起来像:“ wss:// gateway-predix-data-services ....”。
但是,一旦我尝试从dockerized(高山)python应用程序发送时间序列,就会收到以下错误。
SELECT(" * ");
FROM(" student ");
WHERE(" ten LIKE '%' #{ten} '%' ");
相同的代码在docker容器外部有效!在下面,您可以找到我的Dockerfile的内容(我已经隐藏了代理地址):
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]
怎么了?
答案 0 :(得分:1)
我自己弄清楚了! 这确实是我的docker容器的问题,而不是Python代码的问题。 Dockerfile中需要三行:
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 apk --no-cache add ca-certificates
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/"
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"]