Results 1 to 7 of 7

Thread: [RESOLVED] Server Not Responding Issue

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    2,166

    Resolved [RESOLVED] Server Not Responding Issue

    I'm getting data from a Server over which I have no control.
    Sometimes it does not respond and the code I'm using causes the App to freeze.
    Only thing I can think of maybe setting a timer in my program such that if a certain period of time expires
    I exit my Sub that called the Server.

    UPDATE: Changed to Timer and dropped Sleep (forgot it suspends execution)

    Still looking for better alternative.

    Code:
               'Wait Until Server Returns Records
                'or Kill if Error
                Do
                   If (mstrGotRecords = "error") Then
                      frmHD.Caption = "ERROR - Check and Redo Request"
                      Exit Sub
                   Else
                      If (mstrGotRecords = "fin") Then
                          Exit Do
                      Else
                           Call fWait(3)      'API function
    '>>>
                      End If
                   End If
                Loop
    Any other solution appreciated.
    Last edited by dw85745; Mar 10th, 2013 at 01:40 PM.

  2. #2
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    9,017

    Re: Server Not Responding Issue

    What kind of server is it that you're communicating with ?
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    2,166

    Re: Server Not Responding Issue

    Good Question:

    I all know is they're running Java and provide an API to access it.

  4. #4
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    9,017

    Re: Server Not Responding Issue

    Ok...So I assume its a local server ? How is communication to it achieved ? TCP/IP ? Pipes ? Dlls ?
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  5. #5
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: Server Not Responding Issue

    With a loop which i do not recommend,

    Something like this should work
    Code:
        Do Until mstrgotrecords = "fin"
          DoEvents
            If (mstrgotrecords = "error") Then
              frmhd.Caption = "ERROR - Check and Redo Request"
              Exit Sub
            End If
        Loop
    The way I would do it is with a timer.
    Code:
    Private Timer_Seconds As Integer
    Private Timer_TimeOut As Integer
    
    Private Sub RequestRecord(WaitDelay As Integer, Optional TimeOut As Integer = -1)
      Timer_Seconds = 0
      Timer_TimeOut = TimeOut
      Timer1.Interval = WaitDelay
      Timer1.Enabled = True
    End Sub
    
    Private Sub Timer1_Timer()
      Select Case LCase(mstrgotrecords)
      
        Case "error"
          frmhd.Caption = "ERROR - Check and Redo Request"
                 
        Case "fin"
          frmhd.Caption = "FOUND"
         
        Case Else
          If TimeOut_Seconds = Timer_Seconds Then
            frmhd.Caption "TIMEOUT - Check and Redo Request"
          Else
            Timer_Seconds = Timer_Seconds + 1
            Exit Sub
          End If
               
      End Select
      Timer1.Enabled = False
    End Sub
    
    
    Private Sub Command1_Click()
    RequestRecord 2       'No Timeout, timer will keep going!
    'RequestRecord 2, 30  'Timeout after 30 seconds, timer stop after 30 seconds!
    End Sub
    Edit:
    Not sure if once it hits the last "record" and it shows "fin", if so, then forget the timer and use the loop.
    Last edited by Max187Boucher; Mar 10th, 2013 at 09:13 PM.

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    2,166

    Re: Server Not Responding Issue

    Thanks both for input:

    Niya: Yes it is TCP/IP and remote with another firm.

    Max187Boucher:

    Yes, you are correct -- the final record is tagged with "fin".
    Your first example (loop) basically mirrors mine in that if a final record is received ('fin") or the Server sends some kind of error message I can get out of the loop.
    However, if the Server never responds to my request, or hangs then timer only "OUT" I see.
    Appreciate you second code -- IMHO, better logic approach

    ---------------------------------
    You might want to look at: 'Source: MSDN Q231298
    API Timer and IMHO easier to use than VB's
    Last edited by dw85745; Mar 10th, 2013 at 10:28 PM.

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    2,166

    Re: Server Not Responding Issue

    Update:

    For those with "Loop Exit" concerns, you might want to check out
    API-Guide "Wait Message" example.
    Only thing that appears to work in VB's single thread environment without
    resorting to a Background Thread or possibly ActiveX

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