Picture of Wim 4127
Registered 6 years 309 days
Wim 4127 Friday, 12 November 2021, 07:59 AM
1 of 1 users consider this post helpful
Change output of LOG_WEBSOCKET_CLIENT
When using an appwebsocket client instance to get to the devices app for example, I need to enable LOG_WEBSOCKET_CLIENT flag to see incoming/outgoing messages on the websocket clients. However, this logging seems to be hex dumps instead of just logging messages like you do on the server sessions. Logging in green, which is readable and usable to analyse message is from server sessions. Logging in red is from client socket, which is very hard to analyse or view the message. Could you make logging output similar?

AppWebsocketMessageSend {"api":"Services","src":"0","mt":"GetServiceLogin","app":"devices","challenge":"49c2dae55bc6b4c4"} connected:true

WebsocketClient(002376d0,00238c04)::Send state:5 len:455 text:1
11-12 06:51:24.491 7EED9124 - 7B 22 6D 74 22 3A 22 41 70 70 4C 6F 67 69 6E 22 {"mt":"AppLogin"
11-12 06:51:24.492 7EED9134 - 2C 22 61 70 70 22 3A 22 69 6E 6E 6F 76 61 70 68 ,"app":"innovaph
11-12 06:51:24.492 7EED9144 - 6F 6E 65 2D 64 65 76 69 63 65 73 22 2C 22 64 6F one-devices","do
11-12 06:51:24.492 7EED9154 - 6D 61 69 6E 22 3A 22 78 71 74 69 6E 67 2E 62 65 main":"xqting.be
11-12 06:51:24.492 7EED9164 - 22 2C 22 73 69 70 22 3A 22 6B 61 70 73 63 68 6B ","sip":"kapschk
11-12 06:51:24.493 7EED9174 - 75 6E 64 65 6E 61 64 6D 69 6E 22 2C 22 67 75 69 undenadmin","gui
11-12 06:51:24.493 7EED9184 - 64 22 3A 22 33 36 61 65 31 35 33 66 63 64 61 33 d":"36ae153fcda3
11-12 06:51:24.494 7EED9194 - 34 64 38 37 61 63 62 35 38 36 35 63 66 37 32 38 4d87acb5865cf728
11-12 06:51:24.494 7EED91A4 - 33 35 66 35 22 2C 22 64 6E 22 3A 22 6B 61 70 73 35f5","dn":"kaps
11-12 06:51:24.494 7EED91B4 - 63 68 6B 75 6E 64 65 6E 61 64 6D 69 6E 22 2C 22 chkundenadmin","
11-12 06:51:24.495 7EED91C4 - 64 69 67 65 73 74 22 3A 22 35 30 35 65 36 31 38 digest":"505e618
11-12 06:51:24.496 7EED91D4 - 39 65 36 37 37 64 31 63 63 37 39 33 34 39 36 66 9e677d1cc793496f
11-12 06:51:24.497 7EED91E4 - 38 34 66 65 31 35 36 37 36 66 33 61 66 64 64 61 84fe15676f3afdda
11-12 06:51:24.498 7EED91F4 - 65 32 64 62 38 30 36 37 62 64 32 35 39 32 33 66 e2db8067bd25923f
11-12 06:51:24.498 7EED9204 - 39 34 62 36 37 66 64 35 34 22 2C 22 69 6E 66 6F 94b67fd54","info
11-12 06:51:24.499 7EED9214 - 22 3A 7B 22 61 70 70 6F 62 6A 22 3A 22 64 65 76 ":{"appobj":"dev
11-12 06:51:24.499 7EED9224 - 69 63 65 73 22 2C 22 61 70 70 64 6E 22 3A 22 44 ices","appdn":"D
11-12 06:51:24.500 7EED9234 - 65 76 69 63 65 73 22 2C 22 61 70 70 75 72 6C 22 evices","appurl"
11-12 06:51:24.501 7EED9244 - 3A 22 68 74 74 70 73 3A 2F 2F 31 30 2E 30 2E 30 :"https://10.0.0
11-12 06:51:24.501 7EED9254 - 2E 32 34 31 2F 78 71 74 69 6E 67 2E 62 65 2F 64 .241/xqting.be/d
11-12 06:51:24.502 7EED9264 - 65 76 69 63 65 73 2F 69 6E 6E 6F 76 61 70 68 6F evices/innovapho
Picture of Daniel Deterding (innovaphone)
Moderator Registered 15 years 178 days
Daniel Deterding (innovaphone) Friday, 12 November 2021, 09:07 AM
Re: Change output of LOG_WEBSOCKET_CLIENT
Hi Wim,

the hexdump has it's reason. It might be that the received/sent data contains invalid chars which you just see inside a hexdump, not a text dump (which mustn't be JSON at all).

AppWebsocket is different, as we here expect JSON and the websocket connection is closed on wrongly decoded messages.
(in fact we could think about using hexdump here too ...)

Greetings,
Daniel
Picture of Wim 4127
Registered 6 years 309 days
Wim 4127 Friday, 12 November 2021, 10:50 AM
Re: Change output of LOG_WEBSOCKET_CLIENT
No problem, we will again workaround it then and implement our useful logging messages ourselves then.

Dumping all the rest in Hex just makes it worse: given the limited output in the Linux Console Window and the inability to get it in a logfile (or has this already been changed/made better?), it just makes sure the available useful logging information in the console window is even less if you just dump the hex in there.
Picture of Daniel Deterding (innovaphone)
Moderator Registered 15 years 178 days
Daniel Deterding (innovaphone) Friday, 12 November 2021, 11:02 AM
Re: Change output of LOG_WEBSOCKET_CLIENT
No, Microsoft didn't change the limited linux console window yet ...
We also do not understand why it's limited at all.

Btw.: while debugging, the logs are not just written to the linux console but also to the logfiles of the app itself which you can open through the AP Manager.
There you have the standard 5MB limit.

Greetings,
Daniel
Picture of Wim 4127
Registered 6 years 309 days
Wim 4127 Friday, 12 November 2021, 11:01 AM in response to Daniel Deterding (innovaphone)
Re: Change output of LOG_WEBSOCKET_CLIENT
Additionally, your logic is not really consistent. In AppWebsocketClient, I think you also always expect a JSON string as well, since the only callback functions is the AppWebsocketClientMessage funcion in the UAppWebsocketClient class, whihc only has a JSON message parameter for the content. So how would anyone receive a none JSON message? So a none JSON message would have to fail in anyway, which is the logic why you don't dump an disconnect in the AppWebsocket.
Picture of Daniel Deterding (innovaphone)
Moderator Registered 15 years 178 days
Daniel Deterding (innovaphone) Friday, 12 November 2021, 11:09 AM
Re: Change output of LOG_WEBSOCKET_CLIENT
Ah, I missed the App in your initial AppwebsocketClient ...

But the log flag is also used inside the standard websocket client, which can be used outside of the appwebsocket context (ok, now you can ask, why there aren't different log flags, but that's how it works right now) and the appwebsocket client internally uses the websocket client.

Greetings,
Daniel
← You can define your color theme preference here