AnsweredAssumed Answered

PIWebAPI websocket connection for too long URL

Question asked by Robert Raesemann on Mar 15, 2018
Latest reply on Mar 16, 2018 by gregor

I have a rough prototype of an Angular project developed to display live data using a websocket connection to the PIWebAPI. The prototype is working great and I am able to successfully display live data in a table.


To do this, I am using an Angular project developed using the Angular-CLI. I am also using a project called rxjs-websockets (


To get this to work, I pass it the URL with all of the WebIDs that I want to display. Here is an example for displaying 3 of them...




The rxjs-websockets library exposes a method called websocketConnect. If I pass that URL to it, then everything works. I get back an observable of the updates. I then have some code that takes the array of initial values that I get back the first time and updates the values for the items that changed in the latest update. I then massage that array of values into something that is suitable to display in the table.


import { QueueingSubject } from 'queueing-subject' 
import websocketConnect from 'rxjs-websockets' 

this subject queues as necessary to ensure every message is delivered

const input = new QueueingSubject<string>() 

this method returns an object which contains two observables

const { messages, connectionStatus } = websocketConnect('ws://localhost/websocket-path', input)


The problem arises when I need to display too many values to be able to successfully pass the URL. I run into the 16k (or possibly 32k) limit and I get an error.


Daphne Ng posted a workaround to the URL limit. I can post to the PiWebAPI home route with the URL included in a header. If I use this in Postman, I see that it tries to switch to WSS as expected, so it appears that this will fix my URL length problem.


POST to http://corp-web/piwebapi

with the following headers:



My problem now is that I can't see a way to use the POST method with rxjs-websockets. I need to find a way to do the POST to the WebAPI and then capture the resulting WSS stream in an observable. I guess I'm not yet sophisticated enough to know how to go about this. If anyone has any pointers or advice for avenues to pursue, I would greatly appreciate it.