1

MQTT 接続を行う Flask を使用して、Python で Google Cloud Platform アプリを正しくしようとしています。を実行して paho python ライブラリを含めましたpip install paho-mqtt -t libs/。ただし、アプリを実行しようとすると、MQTT に接続しようとしなくても。IP アドレスのチェックで奇妙なエラーが発生します。 RuntimeError: error('illegal IP address string passed to inet_pton',)

ライブラリ内の何かがremote_socket問題を引き起こしているようです。これはセキュリティ上の問題ですか? 無効にする方法はありますか?

関連コード:

from flask import Flask
import paho.mqtt.client as mqtt
import logging as logger


app = Flask(__name__)


# Note: We don't need to call run() since our application is embedded within
# the App Engine WSGI application server.

#callback to print out connection status
def on_connect(mosq, obj, rc):
    logger.info('on_connect')
    if rc == 0:
        logger.info("Connected")
        mqttc.subscribe('test', 0)
    else:
        logger.info(rc)

def on_message(mqttc, obj, msg):
    logger.info(msg.topic+" "+str(msg.qos)+" "+str(msg.payload))

mqttc = mqtt.Client("mqttpy")
mqttc.on_message = on_message
mqttc.on_connect = on_connect

完全なスタック トレースと同様に:

ERROR    2014-06-03 15:14:57,285 wsgi.py:262]
Traceback (most recent call last):
  File "/Users/cbarnes/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 239, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "/Users/cbarnes/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 298, in _LoadHandler
    handler, path, err = LoadObject(self._handler)
  File "/Users/cbarnes/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 84, in LoadObject
    obj = __import__(path[0])
  File "/Users/cbarnes/code/ignite/tank-demo/appengine-flask-demo/main.py", line 24, in <module>
    mqttc = mqtt.Client("mqtthtpp")
  File "/Users/cbarnes/code/ignite/tank-demo/appengine-flask-demo/lib/paho/mqtt/client.py", line 403, in __init__
    self._sockpairR, self._sockpairW = _socketpair_compat()
  File "/Users/cbarnes/code/ignite/tank-demo/appengine-flask-demo/lib/paho/mqtt/client.py", line 255, in _socketpair_compat
    listensock.bind(("localhost", 0))
  File "/Users/cbarnes/google-cloud-sdk/platform/google_appengine/google/appengine/dist27/socket.py", line 222, in meth
    return getattr(self._sock,name)(*args)
  File "/Users/cbarnes/google-cloud-sdk/platform/google_appengine/google/appengine/api/remote_socket/_remote_socket.py", line 668, in bind
    self._SetProtoFromAddr(request.mutable_proxy_external_ip(), address)
  File "/Users/cbarnes/google-cloud-sdk/platform/google_appengine/google/appengine/api/remote_socket/_remote_socket.py", line 632, in _SetProtoFromAddr
    proto.set_packed_address(self._GetPackedAddr(address))
  File "/Users/cbarnes/google-cloud-sdk/platform/google_appengine/google/appengine/api/remote_socket/_remote_socket.py", line 627, in _GetPackedAddr
    AI_NUMERICSERV|AI_PASSIVE):
  File "/Users/cbarnes/google-cloud-sdk/platform/google_appengine/google/appengine/api/remote_socket/_remote_socket.py", line 338, in getaddrinfo
    canonical=(flags & AI_CANONNAME))
  File "/Users/cbarnes/google-cloud-sdk/platform/google_appengine/google/appengine/api/remote_socket/_remote_socket.py", line 211, in _Resolve
    canon, aliases, addresses = _ResolveName(name, families)
  File "/Users/cbarnes/google-cloud-sdk/platform/google_appengine/google/appengine/api/remote_socket/_remote_socket.py", line 229, in _ResolveName
    apiproxy_stub_map.MakeSyncCall('remote_socket', 'Resolve', request, reply)
  File "/Users/cbarnes/google-cloud-sdk/platform/google_appengine/google/appengine/api/apiproxy_stub_map.py", line 94, in MakeSyncCall
    return stubmap.MakeSyncCall(service, call, request, response)
  File "/Users/cbarnes/google-cloud-sdk/platform/google_appengine/google/appengine/api/apiproxy_stub_map.py", line 328, in MakeSyncCall
    rpc.CheckSuccess()
  File "/Users/cbarnes/google-cloud-sdk/platform/google_appengine/google/appengine/api/apiproxy_rpc.py", line 156, in _WaitImpl
    self.request, self.response)
  File "/Users/cbarnes/google-cloud-sdk/platform/google_appengine/google/appengine/ext/remote_api/remote_api_stub.py", line 200, in MakeSyncCall
    self._MakeRealSyncCall(service, call, request, response)
  File "/Users/cbarnes/google-cloud-sdk/platform/google_appengine/google/appengine/ext/remote_api/remote_api_stub.py", line 234, in _MakeRealSyncCall
    raise pickle.loads(response_pb.exception())
RuntimeError: error('illegal IP address string passed to inet_pton',)
INFO     2014-06-03 15:14:57,291 module.py:639] default: "GET / HTTP/1.1" 500 -

ありがとう!

4

1 に答える 1

-1

通常使用する必要があるホストtestとポートに接続しようとしています。0localhost1883

ここで開始例を参照してください: https://pypi.python.org/pypi/paho-mqtt/0.9#usage-and-api

于 2014-07-24T10:13:01.133 に答える