Web Socket (HTTP/SSL) Error 22

I am receiving an error 22 when i try to initiate a web socket post (http or ssl TLS 1.0) sometimes. I am sure I get it and I even put some retry code in which finally connects the socket after 7 attempts. My question is what causes an Error 22? I have found limited prior threads that actually explain it.

Thank you much in advance.
Mike

      eAPI_SSL= new HTTPS_Socket
      Common_Module.WebSocketArray.Append eAPI_SSL
      
      Select Case DynResultsContainerArray(IndexID).WebProtocol
      Case "HTTP"
        Connect_Port = 80
        Connect_Secure_Bool = False
      Case "HTTPS"
        Connect_Port = 443
        Connect_Secure_Bool = True
      End Select
      
      eAPI_SSL.Port = Connect_Port
      eAPI_SSL.DefaultPort = Connect_Port
      eAPI_SSL.IndexID = IndexID
      eAPI_SSL.secure = Connect_Secure_Bool
      eAPI_SSL.ConnectionType = eAPI_SSL.TLSv1
      eAPI_SSL.SetRequestHeader("Accept", "*/*")
      eAPI_SSL.SetRequestHeader("Accept-Encoding:","gzip,deflate,sdch")
      eAPI_SSL.SetRequestHeader("Accept-Encoding:","application/json-rpc")
      eAPI_SSL.SetRequestHeader("User-Agent:","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.101 Safari/537.36")
      eAPI_SSL.SetRequestHeader("Connection", "keep-alive")
      eAPI_SSL.SetRequestHeader("Accept-Language", "en-US,en;q=0.8")
      
      // SET THE JSON FORMATTED STRING IN THE HEADER
      eAPI_SSL.SetRequestContent(inJSONStringToSend, "application/json")
      
      // SET THE USERNAME ON THE SOCKET FOR AUTH
      eAPI_SSL.eAPI_Username = Username_TextField.Text
      eAPI_SSL.eAPI_Password = Password_TextField.Text
      
      
      // SEND THE JSON STRING IN A POST TO THE SERVER
      Dim ConnectCMD as String
      
      if Connect_Secure_Bool = True Then
        ConnectCMD = "https://"
      Elseif  Connect_Secure_Bool = False Then
        ConnectCMD = "http://"
      end if
      Dim URLString as String = ConnectCMD+inDestHostnameString+"/command-api/"
      eAPI_SSL.Post(URLString)

22 is usually invalid argument
It could be almost anything

Ah ok… Weird as it works after a bunch or retries. Norman what would you use to troubleshoot at this point? Watch the response headers?

Good question since 22 is a OS API error and not one of ours
You say a “web socket post” but is thing in a web app or desktop or ?

Thanks for the replies Norman. This is an OS X desktop project doing an https tls JSON-RPC post. Thanks!!