NetTalk Central

Author Topic: NT sync problem  (Read 5764 times)

Alberto

  • Hero Member
  • *****
  • Posts: 1871
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
NT sync problem
« on: July 30, 2019, 04:51:38 AM »
Trying to sync using the server in 127.1.1.0:88 but it does not sync, nothing is seen on the server log, see pic
Ive added a message before the net.sync() to be sure the server url
It seams ok but the server does not receive any request
What can I look for or check?
-----------
Regards
Alberto

Rene Simons

  • Hero Member
  • *****
  • Posts: 650
    • View Profile
Re: NT sync problem
« Reply #1 on: July 30, 2019, 09:42:33 AM »
Hi Alberto,
I think that is because when you use 127.0.0.1:88, in fact you are using local host, which is the device itself.
When you want to sync a different device with the server, you should use the real ip address of the server. E.g. 192.168. xxx.xxx in test circumstances.

Cheers,
Rene
Rene Simons
NT14.14

Alberto

  • Hero Member
  • *****
  • Posts: 1871
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: NT sync problem
« Reply #2 on: July 31, 2019, 04:39:57 AM »
Hi Rene thanks for your post
I dont think so, the template suggest localhost:88 and if its were the problem at least I need to see something in the server log. Anyeay Ive tested with 192.168...... and same errror, nothing in the server log and no sync
Or you mean the sync proc knows its own IP and then do not sync to a server on its own ip?
I know theres no sens on sync over the same DB but the only thing that will happened y that there will be no update, but the proccess must run, its harmless.

Bruce Please what am i doing wrong?

The server works ok, I can see the documentation via URL
My firewall is inactive
Ive checked the server desktop example and it works ok
So its not the server or the PC
Ive made a stanalone exe client and it works
The sln is a multi dll and the client is in the exe app
Then the problem may be the multidll thing
In the client side the queue is made ok with the correct method name
But nothing reachs the server from the client
Ive uncheked the Suppress errors in the client but nothing

Anything I can test by adding some debug lines?
« Last Edit: July 31, 2019, 02:04:41 PM by michelis »
-----------
Regards
Alberto

DonRidley

  • Don Ridley
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 729
  • donaldridley2011@gmail.com
    • View Profile
    • Email
Re: NT sync problem
« Reply #3 on: July 31, 2019, 07:29:51 AM »
Hello Alberto,

I don't know if this is an issue, but you're using an IP address of 127.1.1.0:88 instead of 127.0.0.1:88?

Don
"Eliminate the impossible, whatever remains, however unlikely, must be the truth."

NetTalk 12.55
Clarion 11

Alberto

  • Hero Member
  • *****
  • Posts: 1871
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: NT sync problem
« Reply #4 on: August 01, 2019, 04:29:28 AM »
Ok, no way to make it work in my multidll app, so I try with an external exe.
It seams to work, client send the post to the server
The server receives the post but it does not change the sts value and every sync the client sends 2 records and then the server updates them incrementing the updated records by two.

« Last Edit: August 01, 2019, 05:08:11 PM by michelis »
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: NT sync problem
« Reply #5 on: August 01, 2019, 10:48:08 PM »
send me example apps so I can duplicate here.

cheers
Bruce

Alberto

  • Hero Member
  • *****
  • Posts: 1871
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: NT sync problem
« Reply #6 on: August 02, 2019, 05:33:37 AM »
Difficult to send an example bacause of the mssql db.
I was debuging and testing a lot.
Ill try to explain the issues I found:

Sever side:
If the sts is zero, it happend when you add a new record or you add sts field to an existing table with existing records, the sync allways wants to Insert, the Insert founds a duplicate error and theres no update so sts is never saved then the record is synced every sync.
In the template code, when insert, there are a check for Err to update but it seams not to work.
Workarround: I set all the sts to 1 and now its updating and creating the new sts.

Clien side:

Resumed:
1- everithingafter is not calculated in SQL drivers if you dont have GUID and TS as the first fields in the dct
1.1- everithingafter need to be calculated including the filter
2- All records always send to update if using a filter, pView{prop:filter} does not append the filter but replace it
3- Insert and Delete a records between syncs keeps the sts=0 and dts<>0 then makes the server to try to insert it and you got the same problem indicated in the Server side issue.

Detailed:
1- everithingafter problems: The Debug is saying that the table to sync has no records and this is not true (its sending the correct 2 records to the server), so it always sets everithingafter to -1 and then having or not sts, it allways try to update the same records.
see pic 1

This is the code in NetSync.clw
Code: [Select]
    if Self.ViewTable{PROP:SQLDriver}
      stsname = who(fRecord,pStsKey{prop:field,1})
      Self.ViewTable{prop:sql} = 'Select Max(' & clip(stsname) & '), Count(*) from ' & clip(self.TableLabel)
  message(Self.ViewTable{prop:sql}&' '&fServerTimeStamp&' '&fRecords&' '&errorcode()&' '&error()&' '&fileerror()&' '&fileerrorcode())
      Next(self.ViewTable)
      fServerTimeStamp &= What(fRecord,1)
      fRecords &= What(fRecord,2)
      if fRecords = 0 or errorcode()
        everythingafter = -1
        self.trace('No records in table ' & clip(self.TableLabel) & ' so setting EverythingAfter to -1')
      else
        everythingafter = fServerTimeStamp
      end
      Self.ViewTable{prop:sql} = ''

As you can see Ive added a message to see the porp:sql, see pic2, and its:
   select max(sts),count(*) from operadores
If I run it in the sql studio I get two values without error, but you are getting an sql error "22003 Numeric Error Out of range"

My table is "Operadores" and
its first field (where you are trying to set max(sts)) is LONG in clarion and INT in Sql while sts is REAL in clarion and a float in SQL
its second field ( count(*) ) is cstring(41) in clarion and varchar(50) in sql
its third field is cstring(11)

So just to test I change the prop:sql to set the two sql values to my varchar field like:
Code: [Select]
      Self.ViewTable{prop:sql} = 'Select 0,Max(' & clip(stsname) & '), Count(*) from ' & clip(self.TableLabel)
      Next(self.ViewTable)
      fServerTimeStamp &= What(fRecord,2)  !2nd field
      fRecords &= What(fRecord,3)                 !3rd field

And now without error EverithingAfter is set OK

May be you need to change the way you do the prop:sql, may be using an internal dummy table?
Or the user are forced to have determinated type of fields in the 1rst and 2nd position of the file.
May be in your tests GUID is allways the 1rst and ts the second and never had this error.
But this may be difficult to do in an old app.

Ok, then I went go to my dct and move my 1srt ID field down letting GUID as the first and ts as the second.
Now with that dct change, the Everithingafter is set OK

2- Always send all records problem:

Looking at the NetSync.clw Ive added lines to see the filter and there the problem, see pic 2
Code: [Select]
message('2 '&pView{prop:filter})
  pView{prop:filter} = self.SetFilter(pView{prop:filter})
 message('3 '&pView{prop:filter})

Code: [Select]
self.SetFilter(pView{prop:filter}) is changing the
OPE:TimeStamp <> OPE:ServerTimeStamp
for
ope:idsucursal =1
which is the client filter, instead of adding it like:
OPE:TimeStamp <> OPE:ServerTimeStamp AND ope:idsucursal =1

Then using ope:idsucursal =1 ALL the ope:idsucursal =1 records are sent to the server anytime it synced.

To test it I set the filter manually in the .clw as OPE:TimeStamp <> OPE:ServerTimeStamp AND ope:idsucursal =1
and the problem go away...

But testing a new issue comes out...

3- Add a new record and Cancel the Add:
Insert and Delete a record between syncs makes the sts=0 and dts<>0 then makes the server to insert it and you got the same problem indicated in the Server side issue.
It seams that the server does not set sts when dts<>0

Hope this helps.
« Last Edit: August 03, 2019, 04:47:04 AM by michelis »
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: NT sync problem
« Reply #7 on: August 05, 2019, 09:24:45 PM »
thanks Alberto.