When I hit Realtime API of cumulocity through my local. I m getting 101 response in web socket. getting message id “invalid frame header”
my concern is why i m getting 101 status from web socket
When I hit Realtime API of cumulocity through my local. I m getting 101 response in web socket. getting message id “invalid frame header”
my concern is why i m getting 101 status from web socket
That is just normal accessing a websocket endpoint via http page. To do so the server tells the client to switch protocol to “ws” and making an “upgrade”.
Thanks Stefan, Please describe, I can achieve this from front end or cumolocity will update from server side
It will be help for us.
Hi Rahul,
could you add a few more details to this topic?
Which version of Cumulocity (frontend & backend) do you use?
It seems you are having issues with a custom cockpit application.
Do you see this issue with some of the standard functionalities of the cockpit UI or do you have issues with a custom implementation accessing the realtime API?
If it is an issue with a custom implementation accessing the realtime API, can you show a code snippet of what you are doing?
From the screenshots that you are showing, the 101 Switching Protocols
looks as expected.
Can you check which messages are transferred via the WebSocket connection in the Messages
tab?
Regards,
Tristan
Thanks Tristan
Currently we are using version of Cumulocity mentioned below
Backend: 1015.0.386
UI: 1011.0.12
My code snippet is
this.subscription=this.realtime.subscribe(/measurements/
+this.config.selectedDevices.id, measurementNotification => {
debugger
try {
console.log(measurementNotification.data.data,this.count)
let selectedSeriesWithType = this.supportedSeries1[this.config.selectedDevices.text];
let seriesval1 = selectedSeriesWithType.split(‘.’)
if (measurementNotification.data.data[seriesval1[0]] !== undefined && measurementNotification.data.data[seriesval1[0]][seriesval1[1]] !== undefined) {
const measurementValue= measurementNotification.data.data[seriesval1[0]][seriesval1[1]].value;
if(measurementValue){
this.setValuesToChart(selectedSeriesWithType, measurementValue)
}
}
// setTimeout(() => {
// }, 100);
this.count ++
} catch (e) {
console.log("Advanced Radial Gauge Widget - " + e);
}
Thanks
Rahul
Hi Rahul,
version 1011.0.12 has a bug with websocket connections. If you would have searched for the invalid frame header
message within this forum before posting this, this would have been the first result: Local cumulocity web app dev server is not sending realtime notification - #2 by Tristan_Bastian
This is e.g. also covered as part of the release notes: Applications - Cumulocity IoT Guides
Regards,
Tristan
Hi Tristan,
I checked this issue in the 1015.0.249(UI) and backend(1015.0.386).
it will give me an error (Websocket connection), and after giving the error data will not changed automatically.
Hi Ravi,
I just did a quick check with the 1015.0.249 UI version.
import { Realtime } from '@c8y/client';
[...]
constructor(private realtime: Realtime) {
const deviceId = '1513317632'
const subscription = this.realtime.subscribe(`/measurements/${deviceId}`, measurementNotification => {
console.log(measurementNotification);
});
}
Works without any issues (replace the deviceId with whatever your device of interest is…).
Also consider switching to the MeasurementRealtimeService which is properly typed.
Can you check if you are still running into the issue in a newly setup cockpit app?
Run c8ycli new cockpit cockpit -a @c8y/apps@1015.0.249
and adjust the app.module.ts
for testing to e.g.:
import { AppStateService } from '@c8y/ngx-components';
import { Realtime } from '@c8y/client';
[...]
export class AppModule extends HybridAppModule {
constructor(protected upgrade: NgUpgradeModule, private appState: AppStateService, private realtime: Realtime) {
super();
let subscription;
this.appState.currentUser.subscribe(user => {
if (!user || subscription) {
return;
}
const deviceId = '1513317632'
subscription = this.realtime.subscribe(`/measurements/${deviceId}`, measurementNotification => {
console.log(measurementNotification);
});
})
}
}
Replace the value of deviceId
with one of your devices id.
Regards,
Tristan
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.