Reputation: 78
Hello I have a selenium python script which checks a local webpage for a value.
After a few minuets i get a socket 10055 error (buffer space or queue was full). I am guessing that I check the page too many times and it keeps those connections alive in the buffer and eventually run out of ports.
If I am correct in assuming its just an issue with not closing the connections, how do I go about closing the connections without stopping the code or the ChromeDriver that its using ?
Also I'm not entirely sure why its opening so many connections to cause this error. I only open the page once then check it for a Id and a Value, when there is a value it runs a script and only then does it ever interact with the page. (This error happens when not interacting with the page)
If I am wrong what else could the problem be ? Code listed below.
import os
import sys
import time
import win32com.client
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome()
driver.get("http://192.168.0.3:3333/")
while True:
elem = driver.find_element_by_id('keyvalue')
abc = elem.get_attribute("value")
if abc != '':
shell = win32com.client.Dispatch("WScript.Shell")
shell.Run("notepad++")
shell.AppActivate("notepad++")
time.sleep(0.1)
shell.SendKeys(abc, 0)
driver.execute_script("document.getElementById('keyvalue').value = ''")
Upvotes: 0
Views: 919
Reputation: 6057
I don't think it's the connection to the web page that uses that many sockets but Selenium Webdriver itself. This framework uses of a lot of ephemeral ports and leaves them in TIME_WAIT
status. As you are calling find_element_by_id
in a loop this might be your problem. At least you should move your time.sleep
before the if
check to give your TCP-ports a chance to get closed. You can your port states with netstat -n
in the command line.
Upvotes: 1