I'm betting this is a ssl certificate problem. Try setting verify=False. -tk
On Thu, Aug 16, 2018 at 8:15 AM Pat <[email protected]> wrote: > I'm still thinking about this, and since I can't get the socket.io real > time stream > <https://ambientweather.docs.apiary.io/#reference/ambient-realtime-api> > to work in Python, I thought about using a timer to poll the endpoint. > However it looks like they only update the endpoint every 5 minutes. I'm > thinking that's not really a good option since you probably want real time > loop data, and not a 5 minute archive. > > Since it seems to be working with node, and you're familiar with node, > maybe that's your best bet right now to get the real time updates out of > AW? > > > > Since you're a customer of AW, you could also email them asking for Python > help with the real time endpoint > <https://ambientweather.docs.apiary.io/#reference/ambient-realtime-api> > and see what they say. Their API docs > <https://ambientweather.docs.apiary.io/#reference/ambient-realtime-api> > say "The easiest way to use the API is to use a Socket.io helper library. > They are available in most languages.", but when I use their endpoint with > a Python helper library all I get is a 404. > > Here's the code from sockerIO_client's sample code > <https://pypi.org/project/socketIO-client/>. Nothing fancy here yet, just > trying to connect, and it doesn't. > > After doing sudo pip install socketIO_client > > I ran this code > > import logging > logging.getLogger('socketIO-client').setLevel(logging.DEBUG) > logging.basicConfig() > > > from socketIO_client import SocketIO, LoggingNamespace > > > def on_connect(): > print('connect') > > > with SocketIO(' > https://api.ambientweather.net/?api=1&applicationKey=YOUR_APPLICATION_KEY' > , 443, LoggingNamespace ) as socketIO: > socketIO.on('connect', on_connect) > > > which outputs: > > WARNING:socketIO-client:api.ambientweather.net:443//socket.io [engine.io > waiting for connection] unexpected status code (404 > {"name":"NotFound","message":"Page not > found","code":404,"className":"not-found","errors":{}}) > > Adding your API Key to that HTTPS endpoint: > > with SocketIO(' > https://api.ambientweather.net/v1/devices?applicationKey=YOUR_APPLICATION_KEY&apiKey=YOUR_API_KEY > ', 443, LoggingNamespace ) as socketIO: > socketIO.on('connect', on_connect) > > gave me: > > WARNING:socketIO-client:api.ambientweather.net:443/v1/devices/socket.io [ > engine.io waiting for connection] unexpected status code (401 {"error": > "apiKey-missing"}) > > But the API key isn't missing, it's in the string :) > > > > Or if I did something even different (again from the examples > <https://pypi.org/project/socketIO-client/>) > > SocketIO( > 'https://api.ambientweather.net/v1/devices/YOUR_MAC_ADDRESS', 443, > LoggingNamespace, > params={'apiKey': 'YOUR_API_KEY', 'applicationKey': > 'YOUR_APPLICATION_KEY' }) > > I get > > WARNING:socketIO-client:api.ambientweather.net:443/v1/devices/ > YOUR_MAC_ADDRESS/socket.io [engine.io waiting for connection] unexpected > status code (404 {"name":"NotFound","message":"Page not found","code":404, > "className":"not-found","errors":{}}) > > > > > > However, if I go to an online socket.io test tool > <https://amritb.github.io/socketio-client-tool/>, and enter in your real > time endpoint, it connects just fine. This is farther than Python is > letting me get. > > [image: socketio.png] > Again, not sure where to go from here. Maybe Node is your best bet. But > also maybe the information above is enough info to get help from them if > you do end up reaching out to them? > > > > > On Wednesday, August 15, 2018 at 9:04:34 AM UTC-4, Pat wrote: >> >> No, those are using sockets like how you and I think sockets are. I'm >> familiar with traditional sockets (my SocketLogger driver, and I forked the >> meteostick driver to use sockets).... and I'm familiar with websockets, but >> this is using socket.io which is a websocket, but not a normal websocket >> apparently. It's designed to support old browsers so they use a bit of a >> custom algo to make it happen. >> >> Since AW is using https and not wss, only the socketIO-client Python lib >> will work, but when trying to connect to the endpoint it gives a 404. But >> using the same endpoint on an online JavaScript socket.io test tool, its >> a success. Could be a limitation with the lib. >> >> The AW socket.io endpoint is for the real-time streaming data from >> AmbientWeather. Perhaps plan B is to implement a time.sleep() in the >> driver and just request data every 10 seconds (or something) and submit to >> the loop. Downside could be duplicate timestamps, unless the weewx loop >> already allocates for that? Which could be a non-issue. >> >> >> On Tuesday, August 14, 2018 at 11:39:10 PM UTC-4, gjr80 wrote: >>> >>> So nothing in the vantage or ws1 drivers or restx.py to help? >>> >>> Gary >>> >> -- > You received this message because you are subscribed to the Google Groups > "weewx-user" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "weewx-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
