Hello,
Program connects and works fine but Error -18 still pops up intermittently.
The Clients and Server runs on Windows XP SP2.
Best regards,
%SQLitening_SendOrReceiveError = -18 - Error sending or receiving message"
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.
Have you tried setting ConnectionTimeOut to -1 in SqliteningServer.Cfg
Is the server software up to date, size 125,440 bytes?
Don't test here with XP.
I have tried using -1 and installed the latest Server. Error still showing. The error pops up more frequently now.
The latest server I downloaded and using is ver 1.53 and its 122kb. Its there a newer version?
No newer version than 1.53 at this time. 10/22/2011
Does error happen on all clients or just one? Anything unusual in SQLiteningServer.Log?
This error normally means a TCP/Communications/Network problem.
It happens on the 3 clients presently in use. Nothing unsual I can see in the Log (well, how would anything usual look like?).
Well, for the past hour or so since I changed the value of CONNECTIONTIMEOUT to -1 the error hasn't poped up. Still watching...
Are you saying there is a problem with the network?
SQLiteningServer.log
111022102117 Dcon #16317 TimeOut
If nothing is sent to server within timeout period error 18's appear (as they should) on client.
Refreshing the FACT does not disconnect clients (which is very cool.) :D
Tried several times while changing timeout.
Is there a side effect if you tell the server not to timeout (ConnectionTimeOut=-1)?
Fred or someone else may have to answer this.
When a client ends the server terminates the connection.
My answer is no problem..
QuoteIs there a side effect if you tell the server not to timeout (ConnectionTimeOut=-1)?
Each connection consumes resources at the server (memory/handles/cycles/etc). If you have a client that connects and then leaves for the day you probable should disconnect it. It's your call. If you have a finite number of clients and you have the server resources to have them all connected then no problem.
Thank you for the information. Can I set it to one minute? I.e ConnectionTimeOut=60
Per manual:
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.
It is in minutes, not seconds.
1 = 1 minute (which will force users to send something to the server every 59 seconds or get timed out.)
Are you saying the default value of 30 means 30 minutes? Can we trap error -18 to prevent it from crashing the program anytime it comes up?
Quote
Are you saying the default value of 30 means 30 minutes? Can we trap error -18 to prevent it from crashing the program anytime it comes up?
1) Yes, the documentation says values are in minutes and the default is 30.
2) SQLitening issues an ExiitProcess if an error occurs unless told to return errors.
I use slSetProcessMods("E0") or slSetProcessMods("E1") to return errors and process them.
In the case of errror -18 (a disconnected program ) a slConnect then slOpen would be reissued before continuing.
Others must have a way to handle errors when Sqlitening is allowed to ExitProcess.
You mentioned your program "crashes". It is probably being terminated by Sqlitening, right?
I have a llink to \SqlItening\Doc\SQLitening.Chm on my desktop
slSetProcessMods (rsModChars String)
Sets the process mod flags, modes, and/or values as controlled by the passed ModChars. Some of the mods are global while some are for the open database. No error can occur.
ModChars:
Today, late afternoon, I just got these disconnect problems.
After looking for some time, I verified that a small problem resulted in these disconnects every day, after the system time reaches18:12:16, (if you have not changed the default timeout value of 30).
It is very easy to solve. Change the declaration for
"Local llLastRealMsgTime as Word" to "Local llLastRealMsgTime as Long" you will find the declaration in ConnectionMain.
a 2 byte word can hold only 65535 seconds since midnight. You will reach this limit every day approx. at 18:12:16.
Yes that is a problem. Good catch. I wll post some uptdates soon.
Get version 1.54 here http://www.sqlitening.com/support/index.php?topic=3384.msg17428#msg17428
Gunter, thanks for the information. I would try it out and see how it goes. I have also noticed that it doesn't get to 30 minutes before it times out.
Thank you Fred for the updates.
Great catch and thanks Fred for the 1.54 update..
12:33:20 - 03:26:07 = 9 hours, 7 minutes, 13 seconds or 32833 seconds until disconnect.
111023 032607 Conn #16977 SK 448
111023 123320 Dcon #16977 Dropped
Note:
I need to modify client programs because the first thing I did was a select statement and
after receiving an error 18, end the program to receive a crash. Need to add some
logic to not attempt to perform actions on the server when the connection has been lost.
This is not a big thing, but I can see where clients would call if it occurred.
slGetStatus(4) is currently a way to determine if you are still connected to the server. Will be adding slGetStatus(5) to next release/update which will return the elapsed seconds since the last message was sent to the server. This could be used, along with a timer or sleep loop, to determine when a client should be disconnected due to inactivity. A message could then be displayed to user that they have been disconnected and then they could be reconnected if they request it (like when they return from a long lunch). This along with the ConnectionTimeOut may be a preferred way to control resources at the server.
Thank you, Fred!
Here are some more things to consider:
1) A wireless adapter may connect when you expect a wired connection.
2) The power management property "Allow this computer to turn off this device to save power" might be
checked on any network adapter and the server will later correctly drop the connection.
This "SQLiteningServer.log" shows the last connection last night was wireless on "192.168.1.6".
The connection was expected on the wired connection "192.168.1.4".
11 1025 024044 Conn #8 SK 440 192.168.1.6 connect 02:40:44 AM
11 1025 043746 Dcon #8 Dropped dropped 04:37:46 AM
I am unchecking the save power option on all adapters.
A wireless adapter for connecting to a wireless printer can connect to SQLitening.
How would others configure to not allow a possible connection to SQLitening?
Hello Fred,
In the interim, I'd like to suggest that instead of error message -18 popping up when a user is disconnected. We can have a message of this nature:
"Your system has been idle for over 30 minutes, so have been disconnected. You can restart the program to continue". Its just a suggestion. By this way the clients would understand that the program is not reporting a bug in ones program.
Best regards,
I will try to develop a different message for the -18 error in the next release. Of course, if you are handling errors in your own code then you can display any message you want. You could even re-connect it desired.
This connection (over the internet) lasted almost 7 hours.
The connection was wireless.
10-26-11 09:58:32 Conn #25 SK 440 192.168.1.4
10-26-11 16:37:47 Dcon #25 Dropped
The connection to the mapped drive was also lost. This was NOT a sqlitening issue.
-----------------------------------------------------------------------------------------------------------------
Rebooted client and now testing without a wireless adapter. Server is rock solid.
111026185751 Conn #29 SK 440 192.168.1.7
7 hours for an internet connection via WLAN is pretty good. I noticed from other applications that WLAN connections often collapse just for a short time (a second or less) and are reestablished.
Also here in Germany internet providers automatically disconnect every 24 hours. The router will handle the reconnect.
In any way your SQLitening Server connection is lost. So Fred's suggestion to automatically reconnect when you receive error -18 might be a very good solution.
Rolf
Good information, thank you.
I am doing these tests because many people leave machines on overnight and curiousity.
Wired connection to client dropped in 9h, 39m 57s or 25,797s
10-26-2011 18:57:51 Conn #29 SK 440
10-27-2011 04:37:48 Dcon #29 Dropped
Verified the mapped drive from the client to the server remained.
Now testing with router from client 192.168.1.7 to server 192.168.1.2
10-27-11 06:36:04 Conn #30 SK 440 192.168.1.7
Just a reminder of the different ways the server detects/handles a disconnect. This is displayed in the log following the Dcon entry.
QuoteDcon -- followed by # and the TCP file number and one of the following:
Disconnect = Client issued slDisconnect.
Dropped = Client process ended and the client OS correctly notified the server of that event.
WentAway = Client process ended but the client OS did not notify the server of that event.
TimeOut = Client is inactive (no real messages) longer than the ConnectionTimeOut value in the config file.
Killed = Connection was ended via SQLiteningServerAdmin.
Error = Unrecoverable error occurred.
Testing to see if slGetStatus(4) keeps connections alive overnight.
Have 2 connections running over the internet and 2 running between machines..
The only time that I've seen lock-ups is when waiting to connect and clickng
on a button or attempting to close the dialog. If this is addressed it will
be very hard to lock up a client.
SUB Ping 'only called by TIMER1
LOCAL s AS STRING
INCR gCounter 'not needed, just seeing how many pings are issued
s = slGetStatus(4)
SELECT CASE s
CASE ""
UpdateStatusBar "(" + FORMAT$(gCounter) + ") Ping: Returned nothing"
tConnected = 0
CASE "Yes"
tConnected = 1
UpdateStatusBar "(" + FORMAT$(gCounter) + ") Ping: Connected to " + gsIP
CASE "No"
tConnected = 0
UpdateStatusBar "("+FORMAT$(gCounter) + ") Ping: Not connected"
Connect_OpenDataBase
CASE ELSE
UpdateStatusBar s
END SELECT
END SUB
SUB UpdateStatusBar(sText AS STRING)
LOCAL zText AS ASCIIZ * 80
zText = TIME$ + " " + sText
CONTROL SEND ghDlg, %STATUSBAR, %SB_SETTEXT, 0, VARPTR(zText)
END SUB
slGetStatus does not keep connections alive
All 4 connections were dropped at 04:37:49
These 4 connections were "pinged" every 300 seconds (5-minutes)
Reconnect, re-open worked fine when "No" was returned
I will keep these connections running to see results of the next drop
Could the drop at 04:37:49 been prevented?
111028 013215 Conn #22 SK 440 192.168.1.6 internet
111028 013926 Conn #23 SK 440 192.168.1.6 internet
111028 014740 Conn #24 SK 440 192.168.1.6 intranet
111028 014842 Conn #25 SK 440 192.168.1.6 intranet
111028 043749 Dcon #25 Dropped intranet
111028 043749 Dcon #24 Dropped intranet
111028 043749 Dcon #22 Dropped internet
111028 043749 Dcon #23 Dropped internet
111028 043913 Conn #26 SK 440 192.168.1.6
111028 043928 Conn #27 SK 440 192.168.1.6
111028 044216 Conn #28 SK 440 192.168.1.6
111028 044241 Conn #29 SK 440 192.168.1.6
It is now 11:34 AM CST and all four application still work
The sqliteningserver.log now looks like this:
111028013215 Conn #22 SK 440 CJRIGHT192.168.1.6
111028013926 Conn #23 SK 440 CJRIGHT192.168.1.6
111028014740 Conn #24 SK 440 CJRIGHT192.168.1.6
111028014842 Conn #25 SK 440 CJRIGHT192.168.1.6
111028043749 Dcon #25 Dropped
111028043749 Dcon #24 Dropped
111028043749 Dcon #22 Dropped
111028043749 Dcon #23 Dropped
111028043913 Conn #26 SK 440 CJRIGHT192.168.1.6
111028043928 Conn #27 SK 440 CJRIGHT192.168.1.6
111028044216 Conn #28 SK 440 CJRIGHT192.168.1.6
111028044241 Conn #29 SK 440 CJRIGHT192.168.1.6
111028112346 Conn #30 SK 440 CJRIGHT192.168.1.7
111028112430 Conn #31 SK 440 CJRIGHT192.168.1.7
111028112525 Dcon #27 WentAway
111028112612 Dcon #28 WentAway
111028112637 Dcon #29 WentAway
111028112651 Dcon #26 WentAway
111028112718 Conn #32 SK 440 CJRIGHT192.168.1.7
111028112743 Conn #33 SK 440 CJRIGHT192.168.1.7
4 connections have Dropped and WentAway, so far.
Dcon -- followed by # and the TCP file number and one of the following:
Disconnect = Client issued slDisconnect.
Dropped = Client process ended and the client OS correctly notified the server of that event.
WentAway = Client process ended but the client OS did not notify the server of that event.
TimeOut = Client is inactive (no real messages) longer than the ConnectionTimeOut value in the config file.
Killed = Connection was ended via SQLiteningServerAdmin.
Error = Unrecoverable error occurred.
111028 013215 Conn #22 SK 440 CJRIGHT192.168.1.6
111028 013926 Conn #23 SK 440 CJRIGHT192.168.1.6
111028 014740 Conn #24 SK 440 CJRIGHT192.168.1.6
111028 014842 Conn #25 SK 440 CJRIGHT192.168.1.6
111028 043749 Dcon #25 Dropped
111028 043749 Dcon #24 Dropped
111028 043749 Dcon #22 Dropped
111028 043749 Dcon #23 Dropped
111028 043913 Conn #26 SK 440 CJRIGHT192.168.1.6
111028 043928 Conn #27 SK 440 CJRIGHT192.168.1.6
111028 044216 Conn #28 SK 440 CJRIGHT192.168.1.6
111028 044241 Conn #29 SK 440 CJRIGHT192.168.1.6
111028 112346 Conn #30 SK 440 CJRIGHT192.168.1.7
111028 112430 Conn #31 SK 440 CJRIGHT192.168.1.7
111028 112525 Dcon #27 WentAway
111028 112612 Dcon #28 WentAway
111028 112637 Dcon #29 WentAway
111028 112651 Dcon #26 WentAway
111028 112718 Conn #32 SK 440 CJRIGHT192.168.1.7
111028 112743 Conn #33 SK 440 CJRIGHT192.168.1.7
-------------------------------------------------
Ping counter now at 189. slGetStatus is sent every 5-minutes.
:)
Another drop occurred at: 16:37:49 and autoreconnect still working
111028145659 Dcon #44 Disconnected
111028145816 Conn #45 SK 440 CJRIGHT192.168.1.7
111028145930 Dcon #45 Disconnected
111028150252 Conn #46 SK 440 CJRIGHT192.168.1.7
111028151740 Dcon #46 Disconnected
111028151812 Conn #47 SK 440 CJRIGHT192.168.1.7
111028163749 Dcon #31 Dropped
111028163749 Dcon #32 Dropped
111028163749 Dcon #47 Dropped
111028163749 Dcon #30 Dropped
111028163749 Dcon #33 Dropped
111028163819 Conn #48 SK 440 CJRIGHT192.168.1.7
111028163848 Conn #49 SK 440 CJRIGHT192.168.1.7
111028163932 Conn #50 SK 440 CJRIGHT192.168.1.7
111028164220 Conn #51 SK 440 CJRIGHT192.168.1.7
111028164245 Conn #52 SK 440 CJRIGHT192.168.1.7
111028165721 Dcon #48 Disconnected
Ping counter now at 373. slGetStatus is sent every 5-minutes.
:)
Another drop occurred at: 04:37:50 and autoreconnect still working
Accidently closed one of the over the internet connections. Now 3 active.
111029043750 Dcon #52 Dropped
111029043750 Dcon #49 Dropped
111029043750 Dcon #51 Dropped
111029043750 Dcon #50 Dropped
111029043851 Conn #61 SK 440 CJRIGHT192.168.1.7
111029043935 Conn #62 SK 440 CJRIGHT192.168.1.7
111029044224 Conn #63 SK 440 CJRIGHT192.168.1.7
111029044248 Conn #64 SK 440 CJRIGHT192.168.1.7
Hello Fred,
Quote
I will try to develop a different message for the -18 error in the next release. Of course, if you are handling errors in your own code then you can display any message you want. You could even re-connect it desired.
Error -18 is raring its head at every opportunity at the moment. I need to trap it. I need sample codes to do it and where to place the code.
Thanks.
Error -18 can occur on any command that does TCP messages to the server.
The most common are slSel, slGetRow, and slExe. You can trap errors from
all those commands and take whatever action you desire. If you have a
simple query (a slSel followed by 10 slGetRows) then you could maybe
re-connect, re-open, and re-sel. But, I'm not sure what you could do in a
complex query/update where the error occurs after you have done some
queries and updates.
Can you determine from the SQLitening log what is causing the -18?
Are the TCP/IP traces/logs on the client and/or server that can help?
Maybe someone who is a TCP/IP guru can help.
How are you connected to the network? Cable connection, WLAN, or internet?
Rolf
Hello Rolf,
Quote
How are you connected to the network? Cable connection, WLAN, or internet?
Cable connection (LAN)
Fred,
Quote
The most common are slSel, slGetRow, and slExe. You can trap errors from
all those commands and take whatever action you desire.
Whao. I have plenty of those. It would be nice to do this at the server level. Just need an interim temporary solution: Would be ok?
If Val(sErr) = -18 Then
MsgBox "Disconnected!Your System Has been idle for over 30 minutes. Re-start the program to continue", %MB_TASKMODAL Or %MB_ICONINFORMATION, VD_App.Title
End If
Not sure I understand when you say "to do this at the server level".
SQLiteingServer runs as a service on the server and can't display messages.
Services have no user.
If you want the message that SQLitening.Dll displays when error -18
occurs, just re-compile SQLitening.Bas changing the text that error -18
displays in the routine called slGetError.
With cable connection there really should be no connection problems. I sometimes experience them with interntet connections.
Rolf
Rolf,
Quote
With cable connection there really should be no connection problems. I sometimes experience them with interntet connections.
Though the network is also connected to the internet (any computer on the network can connect to the internet), but I don't use the internet connection. Just the LAN.
I have started getting the same timeouts even with -1.
When they occur, I will just reconnect.
Hello CJ,
I have started getting the same timeouts even with -1.
Same here.
When they occur, I will just reconnect.
[code]
Manually or programmatically?
Something like this:
%ID_TIMER = 500 'must be in the same thread so using a timer
SetTimer(CB.HNDL, %ID_Timer, 30000, BYVAL %NULL) 'check every 30 seconds
FUNCTION AutoStart(hDlg AS DWORD) AS LONG
ConnectToServer hDlg
OpenDatabase hDlg
END FUNCTION
CASE %WM_DESTROY
PostQuitMessage 0
FUNCTION = 0
KillTimer CB.HNDL, %ID_TIMER
EXIT FUNCTION
CASE %WM_TIMER
CALL Ping(CB.HNDL)
FUNCTION Ping(hDlg AS DWORD) AS LONG
LOCAL s AS STRING
s = slGetStatus(4)
IF s <> "Yes" THEN
AutoStart(hDlg)
END IF
END FUNCTION
Fredrick,
Would you check your SqliteningServer.log and see if the IP address is changing.
This is something that is causing -18 errors.
The IP address of the client changed at 18:11:11 from 192.168.1.6 to 192.168.1.7
The ConnectTest.exe program below automatically reconnected to 192.168.1.2 and
a second ConnectTest.exe using the remote ip address also reconnected to 192.168.1.2.
This did not affect the 2 ConnectTest.exe programs running on the server.
Post #31 (from over a year ago) shows the same thing.
Why is the IP address changing?
Running 2 ConnectTest.exe checkers (see below) on the server and 2 ConnectTest.exe on the client.
The local ip address and the remote ip address are being checked on both computers.
Connection #493 and #494 were reconnected as #495 and #496 and connection #493 and #494 WentAway.
slGetStatus(4) <> "Yes" check every 1-minute
130104 161231 Dcon #445 Dropped SERVER LOCAL IP 192.168.1.2
130104 161231 Dcon #448 Dropped REMOTE LOCAL IP 192.168.1.2
130104 173708 Conn #491 SK 424 SERVER LOCAL IP 192.168.1.2
130104 173709 Conn #492 SK 424 SERVER INTERNET 192.168.1.2
130104 173709 Conn #493 SK 424 REMOTE LOCAL IP 192.168.1.6
130104 173710 Conn #494 SK 424 REMOTE INTERNET 192.168.1.6
181111 #493 slGetStatus<>"Yes" 196.128.1.6
181111 #494 slGetStatus<>"Yes" 192.168.1.6
130104 181111 Conn #495 SK 424 REMOTE LOCAL IP 192.168.1.7 New IP
130104 181111 Conn #496 SK 424 REMOTE INTERNET 192.168.1.7 New IP
130104 181403 Dcon #493 WentAway REMOTE LOCAL IP 192.168.1.6
130104 181404 Dcon #494 WentAway REMOTE INTERNET 192.168.1.6
Note: The server has run for a very long time and has never had a problem.
ConnectTest program with auto restart:
#COMPILE EXE "\sql\bin\ConnectTest"
#DIM ALL
#INCLUDE "\sql\inc\sqlitening.inc"
GLOBAL ghDlg, gPingCount AS DWORD
$IP = "192.168.1.2" 'change this
%PortNumber = 51234 'change this
%ID_TIMER = 500
%PingInSeconds = 60 'check slGetStatus(4) <> $Yes
$Yes="Yes"
%USEMACROS = 1
#INCLUDE ONCE "WIN32API.INC"
%IDD_CONNECTTEST = 101
%LISTBOX = 1001
FUNCTION PBMAIN()
CreateConnectTest %HWND_DESKTOP
END FUNCTION
CALLBACK FUNCTION ConnectTestProc()
SELECT CASE AS LONG CB.MSG
CASE %WM_INITDIALOG
ghDlg = CB.HNDL
ConnectToServer
SetTimer(CB.HNDL, %ID_Timer, 1000, BYVAL %NULL) 'change time every second see if 60 seconds
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_COMMAND
' SELECT CASE AS LONG CB.CTL
' END SELECT
CASE %WM_DESTROY
PostQuitMessage 0
FUNCTION = 0
KillTimer CB.HNDL, %ID_TIMER
slDisconnect
EXIT FUNCTION
CASE %WM_TIMER
CALL TimerSub
END SELECT
END FUNCTION
FUNCTION CreateConnectTest(BYVAL hParent AS DWORD) AS LONG
LOCAL lRslt AS LONG
LOCAL hDlg AS DWORD
DIALOG NEW hParent, "Connect Test", 0,0, 201, 92, %WS_POPUP OR _
%WS_BORDER OR %WS_DLGFRAME OR %WS_CAPTION OR %WS_SYSMENU OR _
%WS_MINIMIZEBOX OR %WS_MAXIMIZEBOX 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, , 0, 0, 200, 100, %WS_CHILD OR _
%WS_VISIBLE OR %WS_VSCROLL OR %LBS_NOTIFY, _
%WS_EX_CLIENTEDGE OR %WS_EX_LEFT OR %WS_EX_LTRREADING OR _
%WS_EX_RIGHTSCROLLBAR
DIALOG SHOW MODAL hDlg, CALL ConnectTestProc TO lRslt
FUNCTION = lRslt
END FUNCTION
FUNCTION AutoStart AS LONG
'Add any startup code needed here
ConnectToServer
END FUNCTION
SUB TimerSub
STATIC counter AS LONG
STATIC s AS STRING * 40
s = "Connect Test " + TIME$ + " " +STR$(%PingInSeconds-counter) + " Pings" + STR$(gPingCount)
DIALOG SET TEXT ghDlg, s
INCR counter
IF counter > %PingInSeconds THEN
counter = 0
INCR gPingCount
IF slGetStatus(4) <> $Yes THEN
LISTBOX ADD ghDlg, %LISTBOX, "CONNECT ERROR AT "+ DATE$ + " " + TIME$
AutoStart
END IF
END IF
END SUB
FUNCTION ConnectToServer AS LONG
LOCAL Attempt,Result AS LONG
FOR Attempt = 1 TO 3 'retries
result = slConnect($IP,%PortNumber)
LISTBOX ADD ghDlg, %LISTBOX, "Connect result" + STR$(result) + " at " + TIME$
IF result = 0 THEN
EXIT FUNCTION
END IF
BEEP
SLEEP 1000
NEXT
FUNCTION = Result
END FUNCTION
I have been running ConnectTest above on a server for days and
connections drop on the server at 03:18:48 and 15:18:48 everyday.
I believe someone already posted something about this.
Hello,
Error -18 is an issue that needs to be addressed.
These are the drops in my log the last few days
130122 031848 Dcon #227 Dropped
130122 151848 Dcon #229 Dropped
130123 031848 Dcon #349 Dropped
130123 151848 Dcon #406 Dropped
130124 031848 Dcon #457 Dropped
130124 151848 Dcon #464 Dropped
130125 031848 Dcon #478 Dropped
130125 151848 Dcon #480 Dropped
130126 031848 Dcon #483 Dropped
130126 031912 Conn #484 SK 424
cj - I wanted to follow up on this dropped connections issue. It's not clear from reading through the thread - with respect to the log you mentioned in your last post, what was the ConnectionTimeOut set to in your SqliteningServer.Cfg file? Also, was the client app idle or interacting with the database on a regular basis?
ConnectionTimeOut=-1
Connnections drop everyday at the same time.
cj - I did catch this problem on clients with these steps:
- In WndProc catch the %TCP_MSG and look for %FD_Close in LO(WORD, lParam). If received you can close/kill the connection, release the mutex, etc. and then try to reconnect.
- If you use the console compiler you have to create a hidden (dumy-) window with a message pump first and then create an own small TcpWndProc for that reason.
Sorry, but I did extensive modifications to SQLitening for my own purposes so that it is not possible to show you compatible modifications for the original version. If you have questions, I will try to help if time permits.
Ping or other method works to detect error.
What causes the error is the question.
Here is some code pulled out of a program to test server.
Values are hard-coded to make this posting smaller.
#PBFORMS CREATED V2.01
#COMPILE EXE "\sql\bin\dummy"
#DIM ALL
%CreateError = 0 'cause slGet
#PBFORMS BEGIN INCLUDES
%USEMACROS = 1
#INCLUDE ONCE "win32api.inc"
#INCLUDE ONCE "\sql\inc\sqlitening.inc"
#PBFORMS END INCLUDES
#PBFORMS BEGIN CONSTANTS
%IDD_DIALOG1 = 101
%ID_TIMER = 500
#PBFORMS END CONSTANTS
' ** Declarations **
'------------------------------------------------------------------------------
DECLARE CALLBACK FUNCTION ShowDIALOG1Proc()
DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
#PBFORMS DECLARATIONS
'------------------------------------------------------------------------------
' ** Main Application Entry Point **
'------------------------------------------------------------------------------
FUNCTION PBMAIN()
ShowDIALOG1 %HWND_DESKTOP
END FUNCTION
' ** CallBacks **
'------------------------------------------------------------------------------
CALLBACK FUNCTION ShowDIALOG1Proc()
SELECT CASE AS LONG CB.MSG
CASE %WM_INITDIALOG
SetTimer(CB.HNDL, %ID_Timer, 60000, BYVAL %NULL) 'ping timer was 3000
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
ShutDownHere CB.HNDL
CASE %WM_TIMER
Ping CB.HNDL
CASE %WM_COMMAND
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", 245, 124, 201, 121, %WS_POPUP OR %WS_BORDER _
OR %WS_DLGFRAME OR %WS_CAPTION OR %WS_SYSMENU 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
#PBFORMS END DIALOG
DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
#PBFORMS BEGIN CLEANUP %IDD_DIALOG1
#PBFORMS END CLEANUP
FUNCTION = lRslt
END FUNCTION
'------------------------------------------------------------------------------
FUNCTION Ping(hDlg AS DWORD) AS LONG
LOCAL s, sPrevious AS STRING
s = slGetStatus(4)
DIALOG SET TEXT hDlg, s
IF %CreateError THEN s = "Not 'Yes'"
IF s <> "Yes" THEN
AutoStart hDlg
END IF
BEEP
END FUNCTION
SUB AutoStart(hDlg AS DWORD)
LOCAL result AS LONG
result = ConnectToServer
IF result THEN
KillTimer hDlg, %ID_TIMER
DIALOG END hDlg
END
END IF
OpenDatabase hDlg
END SUB
SUB ShutDownHere(hDlg AS DWORD)
KillTimer hDlg, %ID_TIMER
slDisconnect
'ScreenSettings 1 'write location and size
? "Shut down"
END SUB
FUNCTION ConnectToServer AS LONG
LOCAL Attempt,result AS LONG
FOR Attempt = 1 TO 4
result = slConnect("192.168.1.2",0)
IF result = 0 THEN
EXIT FUNCTION
ELSE
SLEEP 1000
END IF
NEXT
ConnectToServerExit:
FUNCTION = Result
END FUNCTION
FUNCTION OpenDataBase(hDlg AS DWORD) AS LONG
LOCAL result AS LONG
result = slOpen("test.db3","C")
IF result = 0 THEN
DIALOG SET TEXT hDlg, "Opened database
ELSE
DIALOG SET TEXT hDlg, slGetError
END IF
END FUNCTION
QuoteConnnections drop everyday at the same time.
QuoteWhat causes the error is the question.
If loss of connection has nothing to do with SQLitening, it could be very hard to find that problem.
I'm running cj's connect test on my end to see if I get the same results. If the connections don't drop at the same time on my end, I'd say it's very likely that the issue is not in SQLitening.
This is all a bit beyond my arena of programming expertise, but maybe it will mean something to some of you:
http://stackoverflow.com/questions/11712425/do-tcp-sockets-automatically-close-after-some-time-if-no-data-is-sent
I was looking for information on whether WinSock might have some built in connection/timeout settings/limitations.
The server is being pinged so the keep-alive is not an issue.
Notice that a disconnect occurs every 12-hours in my logs above.
I wish the IP address wasn't removed from that posting.
As I recall the IP address of a client changed after disconnecting and
reconnecting when using a wireless connection. This is a continuation
of another posting (which I will try to find.)
Note: In the source code above the 3000 millisecond ping is way to often.
Might change to 30000 or more.
Here is another posting on the same subject:
Start of thread:
http://www.sqlitening.com/support/index.php?topic=3412.0
http://www.sqlitening.com/support/index.php?topic=3412.msg18074;topicseen#msg18074
cj - I ran the connect test program (the one from your earlier post - the one that generated the log of disconnects 12 hours apart) for over 24 hours now with no disconnects. I had the server and client app running on the same computer (in remote mode obviously). It woudl appear that your disconnect issue is not related to SQLitening, but something in your network set up.
cj - my SQLitening application also runs 24/7 for several month now without any disconnect every 24h.
I would second the assumption that it could make some sense to analyse your network setup.
Only connections 192.168,1.3 and higher disconnect. The server is 192.168.1.2.
Is there a lease setting that could make a router drop a connection every 12 hours?
The clients always reconnect when slGetStatus(4) <> "Yes".
Bern, I see you didn't have another machine running the program.
IPCONFIG /RENEW will drop the connections so
I will assume that the 24 hour DHCP lease is being
renewed every 12-hours causing the connections to drop.
Hello,
Does the ConnectionTimeOut= parameter in the config file still equates to 30 minutes? Looks to me its 15 minutes or thereabout. And ConnectionTimeOut=-1 have no effect. Or is it just me?
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.
CJ,
My argument is that the default which is 30 is not really 30 Its 15 or so.
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.
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
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.
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.
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?
With the code I still get error -18. May be there is something I am doing wrong. Would check.
Ok.
>>ConnectionTimeOut=-1 on server.
Mine is ConnectionTimeOut=
Would test with ConnectionTimeOut=-1 tomorrow.
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.