VanDyke Software Forums

VanDyke Software Forums (https://forums.vandyke.com/index.php)
-   General (https://forums.vandyke.com/forumdisplay.php?f=11)
-   -   Exception for "The specified network name is no longer available" (https://forums.vandyke.com/showthread.php?t=14273)

kva 09-02-2020 11:30 PM

Exception for "The specified network name is no longer available"
 
The common part of my script is
Code:

def connect():
    global nr
    for i in range(60):
        if not tab.Session.Connected:
            try:
                tab.Session.Connect()
                nr = tab.Screen.WaitForStrings('#', 20)
                break
            except ScriptError:
                pass
        else:
            nr = True
            break
    else:
        return False
    return nr

def main():
    global nr
    sending, waitingforstring, etc

tab = crt.GetScriptTab()
tab.Screen.Synchronous = True
tab.Screen.IgnoreEscape = True

if connect():
    main()

Sometimes when script tries to connect to unavailable device, the pop-up window tells me: "The specified network name is no longer available". ScriptError does not handle this error? Which exception should?

jdev 09-03-2020 08:59 AM

Quote:

Originally Posted by kva (Post 53964)
Sometimes when script tries to connect to unavailable device, the pop-up window tells me: "The specified network name is no longer available". ScriptError does not handle this error? Which exception should?

In your case, I'm not sure if an exception is even being thrown.

Calling Session.Connect() without args is equivalent to pressing the Reconnect button on the toolbar.

If all you are doing is passing on the exception, why even bother with the exception type? If you just use except: without specifying an exception type, I'm thinking that you would most likely still see the pop-up.

The only way to suppress Connect() related pop-up messages via scripting is to supply parameters to the Connect call sufficient to suppress pop-up messages which, in your case I'm guessing isn't how you want to use Connect() (because you likely want to leverage the fact that the tab has already been connected and you just want to have it reconnected since it's been disconnected for some time).

I've added a feature request for a way via scripting to reconnect a tab without any popups so that you can handle connection errors via a script.

I don't have any ETA on when/if this might ever become available, but if it does we can post here and inform you and the forum community.

--Jake

kva 09-06-2020 10:18 PM

Thank you for hints, Jake.
Catching "Exception" does what I want. I'm satisfied with it. If it will pass for the solution, then the thread may be closed.

jdev 09-08-2020 07:53 AM

Quote:

Originally Posted by kva (Post 53982)
Thank you for hints, Jake.
Catching "Exception" does what I want.

Ha! I'm glad to know that I was so wrong about the majority of my post, but my backup idea worked unexpectedly.

Thanks for trying it out and letting me know.

--Jake

kva 09-09-2020 08:21 PM

Time has passed and base exception handles it no more. I think there were specific network state (ARP state perhaps) on my PC.
Feature request for handling system exceptions or passing specific arguments for connect() is still on :)

jdev 09-10-2020 08:03 AM

Quote:

Originally Posted by kva (Post 53991)
Time has passed and base exception handles it no more. I think there were specific network state (ARP state perhaps) on my PC. Feature request for handling system exceptions or passing specific arguments for connect() is still on :)

Urgh. Sorry that the workaround didn't provide positive results after all. The feature request is still on, and while we don't have any ETA, we'll still plan to post here if there's any movement on it becoming available in a future version of SecureCRT.

Out of curiosity... have you considered simply enabling the Auto reconnect option in the Terminal category of Session Options rather than attempting to reconnect disconnected tabs (silently) using a script?

--Jake

kva 09-21-2020 02:15 AM

Quote:

Originally Posted by jdev (Post 53993)
Out of curiosity... have you considered simply enabling the Auto reconnect option in the Terminal category of Session Options rather than attempting to reconnect disconnected tabs (silently) using a script?
--Jake

Sorry for late answer. Auto-reconnect doesn't match my usage scenarios. Anyway, "the problem" has a lowest priority and actually does not spoil my network life :)


All times are GMT -6. The time now is 12:54 PM.