Jump to content

Chromedriver startup on Virtual Machine


 Share

Recommended Posts

We are running on a VIrtual Machine via Remote Desktop.  We are having a situation where the loading of the chromedriver.exe is taking longer on the VM than on a physical machine.  It is causing the first call to  WD_Post in _WD_CreateSession to fail.

To workaround the Issue, I used a simplified version of (_WinAPI_GetTcpTable) UDF to Loop waiting for the driver port to be in the listening state.  At that point, I know that the Post will work:

Func _WaitForPort($ListenPort)
    Do
        Local $tMIB_TCPTABLE = DllStructCreate("dword[6]")
        Local $aRet = DllCall("Iphlpapi.dll", "DWORD", "GetTcpTable", "struct*", $tMIB_TCPTABLE, "DWORD*", 0, "BOOL", True)
        Local $dwSize = $aRet[2]
        $tMIB_TCPTABLE = DllStructCreate("DWORD[" & $dwSize / 4 & "]")

        $aRet = DllCall("Iphlpapi.dll", "DWORD", "GetTcpTable", "struct*", $tMIB_TCPTABLE, "DWORD*", $dwSize, "BOOL", True)
        If $aRet[0] <> 0 Then Return SetError(1)
        Local $iNumEntries = DllStructGetData($tMIB_TCPTABLE, 1, 1)
        Local $aRes[$iNumEntries][6]

        For $i = 0 To $iNumEntries - 1
            Local $Type = DllStructGetData($tMIB_TCPTABLE, 1, 2 + $i * 5 + 0)
            $aRet = DllCall("ws2_32.dll", "ushort", "ntohs", "uint", DllStructGetData($tMIB_TCPTABLE, 1, 2 + $i * 5 + 2)) ; local port
            Local $Port = $aRet[0]
            ConsoleWrite("Checking Row:" & $i & " State:<" & $Type & "> Port:<" & $Port & ">" & @CRLF)
            ; Type 2 is LISTENING
            If $Type = 2 And $Port = $ListenPort Then
                Return 1;
            EndIF
        Next
        Sleep(500);
    Until 0;

    Return 0;
EndFunc   ;==>_WaitForPort

 

Link to comment
Share on other sites

@JohnWIlling Did you try enabling / setting a greater timeout for the HTTP request? This was a recent addition to the UDF that you can enable like this --

_WD_Option('httptimeouts', True)

These are the defaults from WinHTTP --

$_WD_HTTPTimeOuts[4] = [0, 60000, 30000, 30000]

where the value represent the timeout for Resolve, Connect, Send, & Receive respectively. If you change the array, then these values will be used on the next request as long as the httpTimouts option is true.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...