Trying to connect websocket in ArcGIS Velocity for Vaisala Air Quality sensors, hosted with XWeather. I'm getting an error in ArcGIS Velocity for the first step - just adding in the URI. I do need to incorporate the api key, so I'm wondering if I'm getting the error because there is not a place to add in an api-key header parameters on the first step?
The company confirmed websocket is external and has given me Python to try to make sure my API key is good, but I've never used Python so not really sure how to use that. Ultimately, I really just want to connect to the sensor in ArcGIS Velocity and not worry about python!
Websocket: wss://ws-api.eu.platform.xweather.com
URI to call a specific sensor (I think?):
wss://ws-api.eu.platform.xweather.com/measurement-stream?sensor-id=urn:dev:ops:16961AQT530-V0810232
But gives error in ArcGIS Velocity. Would this be because the api-key is not in the URL? Is there a way to add this into the URL? Or should I be able to connect to the base uri without the parameters?
##
#
# Copyright (c) Vaisala Oyj. All rights reserved.
#
##
import asyncio
import pathlib
import ssl
import websockets
base_uri = "wss://ws-api.eu.platform.xweather.com"
endpoint = "/measurement-stream"
api_key = "" # Place api-key here
sensor_id = "urn:dev:ops:16961-AQT530-V0810232"
uri = f"{base_uri}{endpoint}?sensor-id={sensor_id}"
headers = {"x-api-key": api_key,}
async with websockets.connect(uri, extra_headers=headers) as websocket:
print("WebSocket connection established")
# Receive data once
response = await websocket.recv()
print(f"{response}")
if __name__ == "__main__":
asyncio.get_event_loop().run_until_complete(connect_websocket())
Teresa Blader
Olmsted County GIS Specialist