How to use error handling to deal with Websocket Error

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
songdg
Posts: 565
Joined: 04 Oct 2017, 20:04

How to use error handling to deal with Websocket Error

09 Apr 2021, 01:22

While using Chrome.ahk to do repeated stuff.
gregster
Posts: 9012
Joined: 30 Sep 2013, 06:48

Re: How to use error handling to deal with Websocket Error

09 Apr 2021, 04:58

That's a pretty unspecific question. But generally, the default maximum for websocket connections (at least the way it is done by Chrome.ahk) is 6. If you exceed it, you'll probably get some kind of "security error". Afaik, this limit can be raised by changing the registry (at your own risk).

But generally it is more important to use Chrome.ahk's Disconnect() method on tabs that you are done with. From the Chrome.ahk source code:

Code: Select all

	/*
			Disconnect from the page's debug interface, allowing the instance
			to be garbage collected.
			
			This method should always be called when you are finished with a
			page or else your script will leak memory.
		*/
		Disconnect()
		{  ; [...]
If your question is about something else, please elaborate!
songdg
Posts: 565
Joined: 04 Oct 2017, 20:04

Re: How to use error handling to deal with Websocket Error

11 Apr 2021, 20:54

gregster wrote:
09 Apr 2021, 04:58
That's a pretty unspecific question. But generally, the default maximum for websocket connections (at least the way it is done by Chrome.ahk) is 6. If you exceed it, you'll probably get some kind of "security error". Afaik, this limit can be raised by changing the registry (at your own risk).

But generally it is more important to use Chrome.ahk's Disconnect() method on tabs that you are done with. From the Chrome.ahk source code:

Code: Select all

	/*
			Disconnect from the page's debug interface, allowing the instance
			to be garbage collected.
			
			This method should always be called when you are finished with a
			page or else your script will leak memory.
		*/
		Disconnect()
		{  ; [...]
If your question is about something else, please elaborate!
Thanks, I had been used the Disconnect() function already, but the problem persists.Here is the main structure of my code in a loop.

Code: Select all

open a new tab(used the Findtext library)
GetPage()
do something...
Call("Page.close")
Disconnect()
gregster
Posts: 9012
Joined: 30 Sep 2013, 06:48

Re: How to use error handling to deal with Websocket Error

12 Apr 2021, 10:43

There is still no problem description - for me, this is too unspecific to make another guess.

But if you are only looking generally for some error handling, try and catch might help.

gregster wrote:
09 Apr 2021, 04:58
If your question is about something else, please elaborate!
songdg
Posts: 565
Joined: 04 Oct 2017, 20:04

Re: How to use error handling to deal with Websocket Error

15 Apr 2021, 02:21

gregster wrote:
12 Apr 2021, 10:43
There is still no problem description - for me, this is too unspecific to make another guess.

But if you are only looking generally for some error handling, try and catch might help.

gregster wrote:
09 Apr 2021, 04:58
If your question is about something else, please elaborate!
Now I just comment out the "Websocket Error!" exception in the Chrome.ahk library, and it seems there is no side effects so far.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Araphen, demon740, mapcarter and 306 guests