• Welcome to SQLitening Support Forum.
 

News:

Welcome to the SQLitening support forums!

Main Menu

Error -18 still pops up intermittently

Started by Fredrick Ughimi, October 22, 2011, 07:09:39 AM

Previous topic - Next topic

cj

ConnectionTimeOut = Number Minutes --- Control the number of minutes the server will wait to receive a message
                                             from an active connection.  Default is 30.  Set to -1 if you want to
                                             never timeout.

Fredrick Ughimi

CJ,

My argument is that the default which is 30 is not really 30 Its 15 or so.
Fredrick O. Ughimi<br /><br />fughimi@gmail.com<br />- Freedom lies in being bold -- Robert Frost, Poet

cj

No problem found.
My programs ping the server every 1-minute so had to turn that off.
130428 082255 Conn #18 SK 424 SERVERSERVER192.168.1.2
130428 082257 Conn #19 SK 424 CLIENTCLIENT192.168.1.6
130428 085301 Dcon #18 TimeOut
130428 085322 Dcon #19 TimeOut

Suggestions:
Be sure FACT was refreshed in the log and that nothing sends a request to server.

cj

This is a rough example.
The IP address and other things are in the dialog and didn't want to include all the code.
Please pull out what you need.


#PBFORMS CREATED V2.01

#COMPILE EXE
#DIM ALL
$IPAddress = "192.168.1.2" 'needed something
$PortNumber = "51234"      'needed something
$DataBase  = "test.db3"
%PingInMilliseconds = 1000 'normally 60000
%SimulateDisconnect = 1
%ID_TIMER           =  500
$SoundFile = "chimes.wav"
#PBFORMS BEGIN INCLUDES
#INCLUDE ONCE "WIN32API.INC"
#PBFORMS END INCLUDES
#INCLUDE "sqlitening.inc"

#PBFORMS BEGIN CONSTANTS
%IDD_DIALOG1 =  101
%LISTBOX = 1002
#PBFORMS END CONSTANTS
'------------------------------------------------------------------------------
DECLARE CALLBACK FUNCTION ShowDIALOG1Proc()
DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
#PBFORMS DECLARATIONS
'------------------------------------------------------------------------------
FUNCTION PBMAIN()
  ShowDIALOG1 %HWND_DESKTOP
END FUNCTION
'------------------------------------------------------------------------------
CALLBACK FUNCTION ShowDIALOG1Proc()

  SELECT CASE AS LONG CB.MSG
    CASE %WM_INITDIALOG
      ' Initialization handler
    'ghDlg = CB.HNDL
    SetTimer(CB.HNDL, %ID_Timer, %PingInMilliseconds, BYVAL %NULL)  'create timer
    AutoStart CB.HNDL

    CASE %WM_NCACTIVATE
      STATIC hWndSaveFocus AS DWORD
      IF ISFALSE CB.WPARAM THEN
        ' Save control focus
        hWndSaveFocus = GetFocus()
      ELSEIF hWndSaveFocus THEN
        ' Restore control focus
        SetFocus(hWndSaveFocus)
        hWndSaveFocus = 0
      END IF

      CASE %WM_CLOSE
      'comes after %WM_SYSCOMMAND, but before wm_destroy
      ShutdownHere CB.HNDL


    CASE %WM_DESTROY
       postquitmessage 0 'required with modeless
       EXIT FUNCTION     'modeless with Jose Roca includes
      FUNCTION = 0

    CASE %WM_TIMER
       'might check screen resolution and other things here
       Ping CB.HNDL

    CASE %WM_COMMAND
      ' Process control notifications
      SELECT CASE AS LONG CB.CTL
      END SELECT
  END SELECT
END FUNCTION

'   ** Dialogs **
'------------------------------------------------------------------------------
FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
  LOCAL lRslt AS LONG

#PBFORMS BEGIN DIALOG %IDD_DIALOG1->->
  LOCAL hDlg  AS DWORD

  DIALOG NEW hParent, "Ping Test", 298, 154, 201, 121, %WS_POPUP OR _
    %WS_BORDER OR %WS_DLGFRAME OR %WS_SYSMENU OR %WS_MINIMIZEBOX OR _
    %WS_CLIPSIBLINGS OR %WS_VISIBLE OR %DS_MODALFRAME OR %DS_3DLOOK OR _
    %DS_NOFAILCREATE OR %DS_SETFONT, %WS_EX_CONTROLPARENT OR %WS_EX_LEFT OR _
    %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hDlg
  CONTROL ADD LISTBOX, hDlg, %LISTBOX, , 25, 25, 160, 80, %WS_CHILD OR _
    %WS_VISIBLE OR %WS_TABSTOP OR %WS_VSCROLL OR %LBS_NOTIFY, _
    %WS_EX_CLIENTEDGE OR %WS_EX_LEFT OR %WS_EX_LTRREADING OR _
    %WS_EX_RIGHTSCROLLBAR
#PBFORMS END DIALOG

  DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt

#PBFORMS BEGIN CLEANUP %IDD_DIALOG1
#PBFORMS END CLEANUP

  FUNCTION = lRslt
END FUNCTION
'------------------------------------------------------------------------------
SUB AutoStart(hDlg AS DWORD)
  Message hDlg, ""
  Message hDlg, "AutoStart " + TIME$
  LOCAL result AS LONG
  result = ConnectToServer(hDlg)
  IF result THEN
    KillTimer hDlg, %ID_TIMER
    ? "Unable to access server so program will end",%MB_ICONERROR, EXE.FULL$
    DIALOG END hDlg
    END
  END IF
  OpenDatabase hDlg
  'CONTROL SET FOCUS hDlg, %TEXT_LOWER
END SUB

SUB Player
  LOCAL zFile AS ASCIIZ * 256
  zFile = EXE.PATH$ + $SoundFile 'assumes only sound file and in exe folder
  IF ISFILE (zfile) THEN
    PlaySound(zFile,%NULL,%SND_SYNC)  'always play sound
  END IF
END SUB

'------------------------------------------------------------------------------
FUNCTION ConnectToServer(hDlg AS DWORD) AS LONG

  LOCAL sIPAddress,sPortNumber AS STRING,Result,Attempt AS LONG
  sIpAddress = $IpAddress 'normally passed
  sPortNumber = $PortNumber
  'CONTROL GET TEXT ghDlg, %TEXT_IPADDRESS  TO sIPAddress
  IF LEN(sIPAddress) = 0 THEN
    EXIT FUNCTION 'connect locally
  END IF

  FOR Attempt = 1 TO 4 'retries
    Message hDlg, "Connect attempt" + STR$(Attempt)
    result = slConnect(sIPADDRESS,VAL(sPortNumber))
    IF result = 0 THEN
      Message hDlg, "Connected to " + sIPAddress + " on port " + sPortNumber
      EXIT FUNCTION 'do not enable %BTN_CONNECT so exit function
    ELSE
      Message hDlg, slGetError
      BEEP
      SLEEP 1000
    END IF
  NEXT
ConnectToServerExit:
  FUNCTION = Result
END FUNCTION

FUNCTION OpenDataBase(hDlg AS DWORD) AS LONG
  LOCAL sDatabase AS STRING, result AS LONG
  sDatabase = $Database  'this was passed in real program
  result = slOpen(sDataBase,"C") 'C = create if it does not exist
  ShowVersion
  SELECT CASE result
    CASE 0   :  'LISTBOX ADD hDlg, %LISTBOX,"Database " + $DQ + sDatabase + $DQ + " opened"
      Message hDlg, "Database " + $DQ + sDatabase + $DQ + " opened"
  END SELECT
END FUNCTION

SUB Message(hDlg AS DWORD, sMessage AS STRING)
  LISTBOX ADD hDlg, %LISTBOX, sMessage
END SUB
SUB ShowVersion
  displaysql "select sqlite_version()"
END SUB

FUNCTION DisplaySQL(sql AS STRING) AS STRING
END FUNCTION

SUB ShutDownHere(hDlg AS DWORD)
  KillTimer hDlg, %ID_TIMER
  slDisconnect
  'ScreenSettings 1  'write location and size
END SUB

FUNCTION Ping(hDlg AS DWORD) AS LONG
  LOCAL s AS STRING
  STATIC counter AS LONG
  s = slGetStatus(4)

  IF %SimulateDisconnect THEN
    INCR counter
    IF counter > 3 THEN
       s = ""       'simulate "Yes" not returned
       counter = 1
    END IF
  END IF

  IF s = "Yes" THEN
    DIALOG SET TEXT hDlg, s + " " + TIME$
  ELSE
    BEEP
    AutoStart hDlg
  END IF
END FUNCTION

Fredrick Ughimi

Hello CJ,

Thank you for sharing.

Two quick questions.

1. How do you set the ConnectionTimeOut=? as when you use the above code?
2. Do you use the above codes a separate program or included within the main program?

Thanks ones again.
Fredrick O. Ughimi<br /><br />fughimi@gmail.com<br />- Freedom lies in being bold -- Robert Frost, Poet

cj

#65
1) ConnectionTimeOut  is set in sqliteningserver.cfg. 
This code only pings the server every so many milliseconds and if the connection does
not come back "Yes" the AutoRestart code is executed to reconnect and open database.

2) I use the code within the main program.

Fredrick Ughimi

CJ,

>>1) ConnectionTimeOut  is set in sqliteningserver.cfg. 

Yeah, I know. What is that do you ConnectionTimeOut =-1 or ConnectionTimeOut =30 when you use the above codes. Or does the above codes over writes the ConnectionTimeOut parameter?
Fredrick O. Ughimi<br /><br />fughimi@gmail.com<br />- Freedom lies in being bold -- Robert Frost, Poet

Fredrick Ughimi

With the code I still get error -18. May be there is something I am doing wrong. Would check.
Fredrick O. Ughimi<br /><br />fughimi@gmail.com<br />- Freedom lies in being bold -- Robert Frost, Poet

Fredrick Ughimi

Fredrick O. Ughimi<br /><br />fughimi@gmail.com<br />- Freedom lies in being bold -- Robert Frost, Poet

Fredrick Ughimi

>>ConnectionTimeOut=-1  on server.

Mine is ConnectionTimeOut=

Would test with ConnectionTimeOut=-1 tomorrow.

Fredrick O. Ughimi<br /><br />fughimi@gmail.com<br />- Freedom lies in being bold -- Robert Frost, Poet

cj

#70
Changed ConnectionTimeOut=
Refreshed server shows ConnectionTimeout=30 in SQLiteningServer.log

ConnectionTimeOut = Number Minutes --- Control the number of minutes the server will wait to receive a message
                                             from an active connection.  Default is 30.  Set to -1 if you want to
                                             never timeout.