• Welcome, Guest. Please login.
 
May 22, 2019, 09:12:34 pm

News:

Welcome to the SQLitening support forums!


slDisconnect + slConnect is a killer!

Started by The Tramp, November 02, 2012, 08:14:20 am

Previous topic - Next topic

The Tramp

November 02, 2012, 08:14:20 am Last Edit: November 02, 2012, 08:20:02 am by The Tramp
I have a program that connects to a server.

On the option page, I can also change the language, beside the server.

In any case, when I confirm my changes, I execute the following instructions:

    slClose
    slDisconnect
    OpenDB
[...]
FUNCTION OpenDB( ) AS LONG
    LOCAL sServer AS STRING
    LOCAL lport, lLocal AS LONG
    Showstatus tsl( 258, glang )

    lLocal = VAL( RegDataGet( %HKEY_LOCAL_MACHINE, $RegKey, "Local", "1" ))
    sServer = RegDataGet( %HKEY_LOCAL_MACHINE, $RegKey, "Server", "" )
    lPort = VAL( RegDataGet( %HKEY_LOCAL_MACHINE, $RegKey, "Port", "" ))

    IF NOT lLocal THEN
        slConnect sServer, lPort
        slOpen "JTADataBase.DB3" + $BS + $goon, "C"
    ELSE
        slOpen "SFDataBase.DB3", "C"
    END IF
END FUNCTION           
                   

The program just dies, and I hace to kill it with Task manager.

Under DEBUG, it dies while executing slConnect.                             

BTW: if the database is LOCAL, I do not have this issue.

Fred Meier

I can't cause failure using local host.  Don't see anything in code that would cause problem.  Have you tried a simple connect-disconnect-connect?

   slConnect
   slDisconnect
   slConnect

The Tramp

I told you it does not replicate locally....  ;D

No, you will have to setup a remote server in order to replicate my issue.

Fred Meier

I am using remote mode with a "Local Host" as the server.  This means the server and client are on same computer.  I do all development and testing this way.

The Tramp

I have 2 computers on the same network.

One (192,168.0.2) is acting as the server.
The other (192.168.0.8) is acting as the client.

That is how I replicate my hang.

BTW, your suggestion:
    IF NOT lLocal THEN
        slConnect sServer, lPort
        slDisconnect
        slConnect sServer, lPort
    END IF

is a killer. No messages, no CPU, no program.

It's lost, somewhere. Have to kill the process via Task manager.

On the SQlisteningServer.log I have the Disconnect registered. So it does disconnect but it's loses it's plot while reconnecting.

Dirty fields?

Fred Meier

I installed SQLiteningServer on my wife's laptop(192.168.1.20). Used my desktop as the client(192.168.1.21).
Did the following 20 connects and disconnects without error.  See log below.

   slConnect "192.168.1.20"
   slDisconnect
   slConnect "192.168.1.20"
   slDisconnect
   slConnect "192.168.1.20"
   slDisconnect
   slConnect "192.168.1.20"
   slDisconnect
   slConnect "192.168.1.20"
   slDisconnect
   slConnect "192.168.1.20"
   slDisconnect
   slConnect "192.168.1.20"
   slDisconnect
   slConnect "192.168.1.20"
   slDisconnect
   slConnect "192.168.1.20"
   slDisconnect
   slConnect "192.168.1.20"
   slDisconnect
   slConnect "192.168.1.20"
   slDisconnect
   slConnect "192.168.1.20"
   slDisconnect
   slConnect "192.168.1.20"
   slDisconnect
   slConnect "192.168.1.20"
   slDisconnect
   slConnect "192.168.1.20"
   slDisconnect
   slConnect "192.168.1.20"
   slDisconnect
   slConnect "192.168.1.20"
   slDisconnect
   slConnect "192.168.1.20"
   slDisconnect
   slConnect "192.168.1.20"
   slDisconnect
   slConnect "192.168.1.20"
   slDisconnect


Quote
121104132510 Admn Strt ==========<[ Start Server 1.60 ]>==========
121104132510 Admn Flgs TrimLogManually=No
121104132510 Admn Flgs LogConnDcon=Yes
121104132510 Admn Flgs LogInvalidInMessage=Yes
121104132510 Admn Flgs CreateDatabaseAllowed=Yes
121104132510 Admn Data MaxChunkSize=500
121104132510 Admn Data MaxConnections=0
121104132510 Admn Data ConnectionTimeout=30
121104132510 Admn FACT Loaded
121104132510 Host 192.168.1.20(192.168.1.20)  Socket=516  Port=51234  ServiceNameSuffix=
121104142144 Conn #62 SK 516 FredMEIERDESKTOP192.168.1.21
121104142144 Dcon #62 Disconnected
121104142144 Conn #63 SK 516 FredMEIERDESKTOP192.168.1.21
121104142144 Dcon #63 Disconnected
121104142144 Conn #64 SK 516 FredMEIERDESKTOP192.168.1.21
121104142144 Dcon #64 Disconnected
121104142144 Conn #65 SK 516 FredMEIERDESKTOP192.168.1.21
121104142144 Dcon #65 Disconnected
121104142145 Conn #66 SK 516 FredMEIERDESKTOP192.168.1.21
121104142145 Dcon #66 Disconnected
121104142145 Conn #67 SK 516 FredMEIERDESKTOP192.168.1.21
121104142145 Dcon #67 Disconnected
121104142145 Conn #68 SK 516 FredMEIERDESKTOP192.168.1.21
121104142145 Dcon #68 Disconnected
121104142145 Conn #69 SK 516 FredMEIERDESKTOP192.168.1.21
121104142145 Dcon #69 Disconnected
121104142145 Conn #70 SK 516 FredMEIERDESKTOP192.168.1.21
121104142145 Dcon #70 Disconnected
121104142145 Conn #71 SK 516 FredMEIERDESKTOP192.168.1.21
121104142145 Dcon #71 Disconnected
121104142145 Conn #72 SK 516 FredMEIERDESKTOP192.168.1.21
121104142145 Dcon #72 Disconnected
121104142145 Conn #73 SK 516 FredMEIERDESKTOP192.168.1.21
121104142145 Dcon #73 Disconnected
121104142145 Conn #74 SK 516 FredMEIERDESKTOP192.168.1.21
121104142145 Dcon #74 Disconnected
121104142145 Conn #75 SK 516 FredMEIERDESKTOP192.168.1.21
121104142145 Dcon #75 Disconnected
121104142145 Conn #76 SK 516 FredMEIERDESKTOP192.168.1.21
121104142145 Dcon #76 Disconnected
121104142145 Conn #77 SK 516 FredMEIERDESKTOP192.168.1.21
121104142145 Dcon #77 Disconnected
121104142145 Conn #78 SK 516 FredMEIERDESKTOP192.168.1.21
121104142145 Dcon #78 Disconnected
121104142145 Conn #79 SK 516 FredMEIERDESKTOP192.168.1.21
121104142145 Dcon #79 Disconnected
121104142145 Conn #80 SK 516 FredMEIERDESKTOP192.168.1.21
121104142145 Dcon #80 Disconnected
121104142145 Conn #81 SK 516 FredMEIERDESKTOP192.168.1.21
121104142145 Dcon #81 Disconnected


The Tramp

Right.....

So what's the difference?

I am using a password to connect. What about you?

Fred Meier

QuoteI am using a password to connect. What about you?

Don't understand, there is no password associated with slConnect.

The Tramp

I'm simply trying to understand why it hangs with me and it doesn't with you.

I just tried again, it simply hangs.  >:(

cj

November 05, 2012, 10:07:30 pm #9 Last Edit: November 05, 2012, 10:49:55 pm by cj
Assuming 51234 for the port

Is 192.168.0.2 on the hosts line on the server in SqliteningServer.cfg?
Is the firewall allowing the remote port 51234?
Is the router forwarding 51234 to 192.168.0.2?
Tried hard-coding 192.168.0.2 and the port number instead of using the registry?
slConnect   "192.168.0.2" ,51234


It should be one of these 2 things:
Turn off firewall on server and see if it works.
In router, port forward the port to 192.168.0.2.

Verify that the IP address didn't change on server:
At command prompt:
IPCONFIG and press Enter
Does it say 192.168.0.2?

In a previous posting was 192.168.0.3 used with port 1113?

cj

Test program on client

'\sql\examples\tramp.bas
#DIM ALL
#COMPILE EXE "\sql\bin\tramp.exe"
#INCLUDE "\sql\inc\SQLitening.Inc"
#INCLUDE "win32api.inc"
$separator = "  "

TYPE InfoStruct
    startdate AS DOUBLE
    enddate AS DOUBLE
    Direction AS BYTE
    LotSize AS SINGLE
    Level AS BYTE
    StartPrice AS SINGLE
    endprice AS SINGLE
    Profit AS SINGLE
    Balance AS QUAD
END TYPE

FUNCTION PBMAIN () AS LONG

    LOCAL x, NumRecs, MaxField AS LONG
    DIM ArStats() AS STRING
    LOCAL record() AS InfoStruct 'all the lines

    slConnect "192.168.0.2",51234
    slOpen "TestBind.DB3", "C"
    slExe "Drop Table If Exists Stats00F"
    slExe "Create Table If Not Exists Stats00F (IDname, SFhash, idx, StartDate, EndDate, Direction, LotSize, Level, StartPrice, EndPrice, Profit, Balance)"
    NumRecs= 250  'Change this
    MaxField = 12
    REDIM record(1 TO NumRecs)
    FOR x = 1 TO NumRecs
        record(x).StartDate = 150012.123
        record(x).EndDate = 150012.456
        record(x).Direction = 1
        record(x).LotSize = 0.01
        record(x).Level = (x AND 7) +1
        record(x).StartPrice= 1.2345
        record(x).EndPrice= 1.4567
        record(x).Profit= .47
        record(x).Balance= 47 * x  'pennies used instead with a QUAD
    NEXT x
    REDIM ArStats(1 TO NumRecs*MaxField)
    FOR x = 1 TO NumRecs
        'First 3 fields
        ArStats((x-1)*MaxField+1) = slBuildbindDat( "EVV13", "T" )     'IDNAME
        ArStats((x-1)*MaxField+2) = slBuildbindDat( "12345678", "T" )  'SFHash
        ArStats((x-1)*MaxField+3) = slBuildbindDat( FORMAT$( x ), "i" ) 'idx

        'Other 9 fields from record(array)
        ArStats((x-1)*MaxField+4) = slBuildbindDat( FORMAT$(record(x).StartDate), "D" )
        ArStats((x-1)*MaxField+5) = slBuildbindDat( FORMAT$(record(x).EndDate), "D" )
        ArStats((x-1)*MaxField+6) = slBuildbindDat( FORMAT$(record(x).Direction), "i" )
        ArStats((x-1)*MaxField+7) = slBuildbindDat( FORMAT$(record(x).LotSize), "D" )
        ArStats((x-1)*MaxField+8) = slBuildbindDat( FORMAT$(record(x).Level), "i" )
        ArStats((x-1)*MaxField+9) = slBuildbindDat( FORMAT$(record(x).StartPrice), "D" )
        ArStats((x-1)*MaxField+10) = slBuildbindDat( FORMAT$(record(x).EndPrice), "D" )
        ArStats((x-1)*MaxField+11) = slBuildbindDat( FORMAT$(record(x).Profit), "D" )
        ArStats((x-1)*MaxField+12) = slBuildbindDat( FORMAT$(record(x).Balance), "i" )
    NEXT x
    slExe "Begin" 'added
    slExeBind "Insert into Stats00F values(?" + REPEAT$( 11, ",?" ) + ")", JOIN$( ArStats( ), "" ), "V" & FORMAT$(MaxField)
    slExe "End"
    DisplayRecordSet "Select ROWID, * from Stats00F Order by idx desc"
END FUNCTION

SUB DisplayRecordSet(BYVAL s AS STRING)
  LOCAL TotalRows,ThisColumn,TotalColumns, hFile AS LONG
  LOCAL sLine                      AS STRING
  hFile = FREEFILE
  OPEN "MyData.txt" FOR OUTPUT AS hFile
  slSel s
  TotalColumns = slGetColumnCount
  DIM sField(1 TO TotalColumns) AS STRING
  IF TotalColumns THEN
    DO WHILE slGetRow
      INCR TotalRows
      FOR ThisColumn = 1 TO TotalColumns-1
        sField(ThisColumn) = slf(ThisColumn)
      NEXT
      sField(TotalColumns) = Money(VAL(slf(ThisColumn)))  'test money using QUAD
      sLine = JOIN$ (sField(),$separator)
      PRINT #hFile,sLine
    LOOP
  ELSE
    PRINT #hFile, "Search did not return any columns that matched the query."
  END IF
  CLOSE #hFile
  ShellExecute(BYVAL 0, "OPEN", "MyData.txt" + $NUL,BYVAL 0, CURDIR$, %SW_SHOWNORMAL)
END SUB

FUNCTION money(pennies AS QUAD) AS STRING
  FUNCTION = LEFT$("-",-(pennies <0)) + LTRIM$(LEFT$(STR$(ABS(pennies\100)),-(pennies\100<>0)*9)) + "." + RIGHT$("0" + MID$(STR$(ABS(pennies)),2),2)
END FUNCTION
                                                                                                                   

cj

November 05, 2012, 10:42:23 pm #11 Last Edit: November 05, 2012, 10:56:16 pm by cj
Here is some code if it turns out tthe firewall is blocking the port.

http://www.sqlitening.com/support/index.php?topic=3402.msg17341#msg17341

What is in SQliteningServer.Cfg?  Looking at an earlier posting.
Port = 1113
Hosts = 192.168.0.3

The Tramp

cj, I have no problem in connecting (the port is 1113, BTW)

My program works overall, but if I ececute:

    IF NOT lLocal THEN
        slConnect sServer, lPort  ' Takes 2 seconds - it connects
        slDisconnect              ' disconnects instantly
        slConnect sServer, lPort  ' this takes for ever - have to kill the process from the task manager
    END IF


Now, I know what you are asking - why should disconnect and reconnect?
Because I want to change server! Now I have to ask the user to close the window and restart the program to connect to the new server - because if the program does it, it dies.... (it's not an infinite loop, there is no CPU usage on either system)

cj

November 06, 2012, 03:05:45 pm #13 Last Edit: November 06, 2012, 03:09:47 pm by cj

'100 times takes 5 seconds hard wired.
'100 times using remote ip address takes about the same.
#DIM ALL
#COMPILE EXE "\sql\bin\ConnectTest.exe"
#INCLUDE "\sql\inc\SQLitening.Inc"
#INCLUDE "win32api.inc"
FUNCTION PBMAIN AS LONG
  LOCAL x AS LONG, StartTime AS STRING
  StartTime = TIME$
  FOR x = 1 TO 100
    slConnect "192.168.1.2",0
    slDisconnect
  NEXT
  ? TIME$ + "  " + StartTime
END FUNCTION
   

cj

November 06, 2012, 03:30:41 pm #14 Last Edit: November 06, 2012, 03:33:02 pm by cj
Here is  part of my SqliteningServer.Cfg on the server:

[General]
ServiceNameSuffix=
Port = 51234
Hosts = 192.168.1.2
LogConnDcon=Yes
LogInvalidInMessage=Yes
CreateDatabaseAllowed=Yes
TrimLogManually=No
MaxChunkSize=
MaxConnections=
ConnectionTimeOut=

[FACT]

Just guessing now:
Turn off firewall on both machines.
Reboot both computers and router.
Turn off any virus checkers.

Are you using WIFI?