Results 1 to 6 of 6

Thread: I do not get any Response of httpWebRequest in windows server 2012 R2.

  1. #1

    Thread Starter
    Member buzz4rd's Avatar
    Join Date
    Feb 2012
    Posts
    42

    Unhappy I do not get any Response of httpWebRequest in windows server 2012 R2.

    I'm using httpWebRequest in vs 2017 VB.NET. It works fine in windows 10. But I do not get any Response in windows server 2012 R2. How to fix it?
    please

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,102

    Re: I do not get any Response of httpWebRequest in windows server 2012 R2.

    It's the exact same code?

    I'm not sure that no response is even possible. Perhaps you'll have to show us how you are sending the response. In my experience, you get one of three alternatives: A response, an exception, or a hang. You wouldn't be able to avoid noticing that last one.
    My usual boring signature: Nothing

  3. #3

    Thread Starter
    Member buzz4rd's Avatar
    Join Date
    Feb 2012
    Posts
    42

    Re: I do not get any Response of httpWebRequest in windows server 2012 R2.

    Code:
        Public Sub mRequest()
    
            If taskRun = True Then
    
                Task.Run(Sub()
    
                             Try
                                 OnPingTime.Invoke("Info", "Connecting ...." & Me.actionURL)
                                 Dim formUrl As String = "URL"
                                 Try
                                     Dim req As HttpWebRequest = CType(WebRequest.Create(formUrl), HttpWebRequest)
                                     req.Method = "GET"
                                     req.Host = "HOST"
                                     req.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
                                     req.Headers.Add("Accept-Language", "en-US,en;q=0.5")
                                     req.Headers.Add("Accept-Encoding", "gzip, deflate")
                                     req.UserAgent = UserAgent
                                     req.CookieContainer = cook
                                     req.Referer = Me.actionURL
                                     req.KeepAlive = True
                                     'req.Proxy = proxy;
                                     Const contentType As String = "application/x-www-form-urlencoded; charset=UTF-8"
                                     req.ContentType = contentType
                                     Try
                                         Dim resp As HttpWebResponse = CType(req.GetResponse(), HttpWebResponse)
                                         Dim stremResponse As Stream = resp.GetResponseStream()
                                         If resp.ContentEncoding.ToLower().Contains("gzip") Then
                                             stremResponse = New GZipStream(stremResponse, CompressionMode.Decompress)
                                         ElseIf resp.ContentEncoding.ToLower().Contains("deflate") Then
                                             stremResponse = New DeflateStream(stremResponse, CompressionMode.Decompress)
                                         End If
                                         Dim srd As New StreamReader(stremResponse)
    
                                         response = srd.ReadToEnd()
    
                                         Dim html As New HtmlDocument()
    
                                         html.LoadHtml(response)
    
                                     Catch ex As WebException
    
                                         If ex.Status = WebExceptionStatus.ProtocolError OrElse ex.Status = WebExceptionStatus.ConnectFailure OrElse ex.Status = WebExceptionStatus.NameResolutionFailure OrElse ex.Status = WebExceptionStatus.Timeout OrElse ex.Status = WebExceptionStatus.ProxyNameResolutionFailure Then
                                             Dim response = TryCast(ex.Response, HttpWebResponse)
                                             If response IsNot Nothing Then
                                                 If CInt(response.StatusCode) >= 500 Then
                                                     Thread.Sleep(1000)
                                                     If AutoRetry = True Then Start()
                                                 Else
    
                                                 End If
                                             Else
                                                 Thread.Sleep(1000)
                                                 If AutoRetry = True Then Start()
                                             End If
                                         Else
    
                                         End If
                                     End Try
    
                                 Catch e As Exception
                                     '_msg.Add(e.Message)
                                     Thread.Sleep(1000)
                                     If AutoRetry = True Then Start()
    
                                 End Try
    
                             Catch ex As Exception
    
                             End Try
    
                         End Sub)
    
            End If
    
        End Sub
    This is My Code. I just Get Connecting ....
    please

  4. #4

    Thread Starter
    Member buzz4rd's Avatar
    Join Date
    Feb 2012
    Posts
    42

    Re: I do not get any Response of httpWebRequest in windows server 2012 R2.

    Please check the code above.
    Last edited by buzz4rd; Sep 4th, 2018 at 11:31 AM. Reason: duplicate content
    please

  5. #5
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,102

    Re: I do not get any Response of httpWebRequest in windows server 2012 R2.

    I would suggest that for testing purposes you should take it out of the task. That would make it easier to step through and debug. You may be getting a hang. Since you are running this in a Task, a hang would essentially go on forever without you ever knowing about it. The Task simply wouldn't complete. If I remember right, the hang would come on GetResponse. Solving it is a different matter, as I have yet to see it consistently, but the first step would be to figure out if that really was the issue.
    My usual boring signature: Nothing

  6. #6
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: I do not get any Response of httpWebRequest in windows server 2012 R2.

    If that's the exact code you're using, with no alterations what so ever, I can tell you exactly what the problem is (1). Why it worked in Win10, I couldn't say, except that odds are it probably didn't and the exception was swallowed (2). Ick... I wished now I hadn't looked at that code a second time, it's making me twitch(3).

    -tg

    (1) - reference the formUrl variable value
    (2) - referencing the empty catch
    (3) - good grief, empty else...end if and the previously mentioned empty catch.
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width