RTC Forums
March 28, 2024, 06:08:49 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1] 2 3
  Print  
Author Topic: Ambiguos gate client disconnection  (Read 19481 times)
ISIGest
RTC Expired
*
Posts: 121


« on: August 29, 2016, 10:40:04 AM »

Hi Danijel, I've a Gate Server with 50 clients connected.
One of these was disconnect every 30 seconds.
What should I check?
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 on: August 29, 2016, 11:08:30 AM »

The most probable cause for this is poor connection between the Gateway and the Gate Client, but it could also be a number of other things.

To help analyze the problem, please answer these questions first:

1. Which RTC SDK version did you use to compile the Gateway and that specific Gate Client? If you were using some older RTC SDK version, did you try recompiling the Gateway and Gate Clients with the latest RTC SDK version (v7.33) to see if that fixes the problem?

2. Which Delphi version did you use to compile the Gateway and that specific Gate Client?

3. What target platform did you compile the Gateway to and what is the target platform of that specific Gate Client? (Win32, Win64, MacOSX, iOS32, iOS64 or Android)

4. What kind of a connection is the problematic Gate Client using to conencting to the Gateway? Is it inside the same LAN as the Gateway, or over the Internet?

5. If that Gate Client is connecting to the Gateway over the Internet, is the Gate Client using a fast fixed-line internet connection or a mobile connection?

6. How much network bandwidth does your Gateway have available for handling all the Gate Clients?

7. What network/internet bandwidth do your "working" Gate Clients have and what bandwidth does your problematic Gate Client have?

8. Is that problematic Gate Client beihind a firewall or behind a Proxy or is some Anti-Virus software running on the Client machine? If that Gate Client is running on Window, which Windows version? If it is one of the newer Windows versions, is the "Windows Defender" active?

9. How is the TRtcHttpGateClient component configured on the problematic Gate Client? Please, list all the components properties (except GateAddr and GatePort).

Best Regards,
Danijel Tkalcec
Logged
ISIGest
RTC Expired
*
Posts: 121


« Reply #2 on: August 29, 2016, 11:57:04 AM »

1. RTC 7.33
2. XE10
3. XE10
4. Over internet
5. Fast fixed-line
6. Gateway is on a dedicated server with 200Mb/s bandwidth
7. I'm not sure on this!
8. On this client is only installed AVG antivirus.
9.
Code:
  object GateCli: TRtcHttpGateClient
    GateAddr = 'myaddress'
    GatePort = 'myport'
    GateFileName = '/'
    GatePrimaryKey = 'myKey'
    GateUserAuth = 'user'
    StreamBlockSizeOut = 124998
    BeforeLogIn = GateCliBeforeLogIn
    OnDataReceived = GateCliDataReceived
  end

The problem is only on a single client, also on this client (and all others) I use RtcModule that connect on other server with a callback connection a it never disconnect.


This is my log:
Code:
2016-08-29 12:59:00.439; Before Log IN 506636:  /
2016-08-29 12:59:00.504; Before Log IN 402595: myApp / USERDATA
2016-08-29 12:59:00.683; User Ready 402595: myApp / USERDATA
2016-08-29 12:59:36.548; Before Log OUT 144186: myApp / USERDATA
Logged
ISIGest
RTC Expired
*
Posts: 121


« Reply #3 on: August 29, 2016, 12:49:10 PM »

I found some issue:
Into GateBeforeUserLogin event I check UserAuth and UserInfo parameters and for this client are empty.
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #4 on: August 29, 2016, 01:44:27 PM »

Most Anti-Virus software is buffering all outgoing data and forwarding the request ONLY after the complete request content is sent by the Client. To make the Client work in that scenario, you have to disable Clients streaming for outgloing data by setting the StreamBlockSizeOut property to 6 (PING packet size). If you use a higher value, your Client will NOT be able to send PING messages to the Gateway and the Gateway will disconnect the Client because of inactivity on the incoming streaming.

Even though this is less common, some Anti-Virus software and Proxy Servers could also be buffering incoming data and forwarding the response to the Client ONLY after the complete responce has been received from the Gateway, making it impossoble for the Gateway to send periodical PING packages through an open conection to the Client, in whcih case Client will be the one closing the conneciton because of inactivity. If your CLient is behind such a Proxy or Anti-Virus software, you will also have to disable the incoming stream on the Client by setting the StreamBlockSizeIn property to 6.

Let me know if changing either of these parameters makes a difference for that Client.

Best Regards,
Danijel Tkalcec
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #5 on: August 29, 2016, 01:56:04 PM »

As for the "UserInfo" and "UserAuth" parameters being empty on the Gateway, implement the AfterLoggedIn event on the TRtcHttpGateClient component to write down the following values:

Client.GateUserAuth
Client.GateUserInfo
Client.MyUID
Client.MyIP

To check if these values match for the Client, in addition to the info you are already logging on the Gateway inside the BeforeUserLogin event, write down these parameters:

TRtcDataServer(Sender).Request.URI
TRtcDataServer(Sender).Request.HeaderText
TRtcDataServer(Sender).PeerAddr

Let me know what comes out on both ends.

Best Regards,
Danijel Tkalec
Logged
ISIGest
RTC Expired
*
Posts: 121


« Reply #6 on: August 29, 2016, 04:07:01 PM »

I try with StreamBlock beacuse the UseInfo is needed to ahndle before login to check if client have valid information to be logged in, and if I use AfterLogin this information is blank into onBeforeLogin on the Gate.
Logged
ISIGest
RTC Expired
*
Posts: 121


« Reply #7 on: August 29, 2016, 04:39:26 PM »

I've tested by changing StreamBlockSizeOut but it doesn't work.

I need this values
Client.GateUserAuth
Client.GateUserInfo

not empty into BeforeUserLogin (Gate Server) because I check this values to check a valid login.

If I implement the AfterLoggedIn this values became empty into GateBeforeUserLogin event.
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #8 on: August 29, 2016, 04:45:28 PM »

StreamBlockSize properties only define streaming properties.
They have nothing to do with UserInfo and UserAuth parameters.

1. Did you change GateCli:TRtcHttpGateClient component to use this?
StreamBlockSizeOut := 6;
StreamBlockSizeIn := 6


2. Did you write AfterLoggedIn event for GateCli:TRtcHttpGateClient component to log this?
Log('UserAuth='+Client.GateUserAuth);
Log('UserInfo='+Client.GateUserInfo);
Log('UID='+IntToStr(Client.MyUID));
Log('IP='+Client.MyIP);

This event should NOT make any changes to the component. It should ONLY log current property values.

3. Did you write the OnBeforeLogin event on the Gateway to log this?
Log('URI='+TRtcDataServer(Sender).Request.URI);
Log('Header='+TRtcDataServer(Sender).Request.HeaderText);
Log('Addr='+TRtcDataServer(Sender).PeerAddr);

Best Regards,
Danijel Tkalcec
Logged
ISIGest
RTC Expired
*
Posts: 121


« Reply #9 on: August 29, 2016, 04:51:53 PM »

1. Oh Smiley yes I know...

2. I populate Client.GateUserInfo on client like:
Code:
Client.GateUserInfo := 'I AM AN USER WITH SOME PROPERTIES';

and check this value into GateBeforeUserLogin event on server.
Is this the correct method or not?

This is the log:

2016-08-29 17:52:01.278; Addr=95.231.151.x
2016-08-29 17:52:01.292; URI=/$l
2016-08-29 17:52:01.302; Header=CONTENT-LENGTH: 48


I've do that because into your demos I see that:

 { User is logging in. Check "UserAuth" if Login is allowed and raise an exception if not.
    Because we ONLY want to accept users with UserAuth "MyChatClient",
    we will raise an exception for all other Clients.

    If you want to accept other Clients,
    the lines below have to be commented out ... }
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #10 on: August 29, 2016, 05:23:00 PM »

Your Gateway log shows that the Gateway has received 48 bytes of concent in the login request, which probably means that the Gate Client has sent 44 bytes of UserInfo and/or UserAuth. But since "UserInfo" and "UserAuth" parameters are both empty in the BeforeUserLogin event on the Gateway, my guess is that the GateClient is using the wrong encryption key to encrypt that data before sending.

There are 2 parts of the encryption code used here.

First is the GatePrimaryKey, which has to be 100% identical on the Gateway and GateClient components.
The second part is calculated by the Gateway based on the users IP Address and the Forwarded-for HTTP header value.

If you are 100% sure that the GatePrimaryKey value set on the GateClient is identical to the one used by your Gateway,
then you should check the IP address generated by the Gateway for that Client.
To do this, enter your Gateways address with "/$p" in a Web Browser on the Client PC, like this:
http://<your_gateway_address>/$p

Try it several times, using at least 2 different Browser windows to see if the Address chaanges and
check if it is the same address logged by the Gateway inside the GateBeforeUserLogin event for that Client.

Best Regards,
Danijel Tkalcec
Logged
ISIGest
RTC Expired
*
Posts: 121


« Reply #11 on: August 29, 2016, 05:57:45 PM »

I've tested it and the GatePrimaryKey is obviously same Smiley
However I've tested also the Client IP with /$p pararm into the browser and also the IP address is same Sad
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #12 on: August 29, 2016, 06:02:06 PM »

I think, I have found the problem.

Are you using the TRtcGateway component with a TRtcHttpServer component?

If you are, can you check the MultiThreaded property on the TRtcHttpServer component?

Best Regards,
Danijel Tkalcec
Logged
ISIGest
RTC Expired
*
Posts: 121


« Reply #13 on: August 29, 2016, 06:12:17 PM »

Yes it's TRUE, this is my HTTPServer

Code:
object HTTPServer: TRtcHttpServer
  MultiThreaded = True
  Timeout.AfterConnecting = 240
  ServerAddr = '127.0.0.1'
  OnException = HTTPServerException
  RestartOn.ListenLost = True
  RestartOn.ListenError = True
  OnListenStart = HTTPServerListenStart
  OnListenStop = HTTPServerListenStop
  OnListenError = HTTPServerListenError
  FixupRequest.RemovePrefix = True
  OnRequestNotAccepted = HTTPServerRequestNotAccepted
  MaxHeaderSize = 2048
  OnInvalidRequest = HTTPServerInvalidRequest
  TimeoutsOfAPI.SendTimeout = 180
  TimeoutsOfAPI.ReceiveTimeout = 180
end
Logged
ISIGest
RTC Expired
*
Posts: 121


« Reply #14 on: August 29, 2016, 06:30:49 PM »

I've check some logs and I see the "UserAuth" and "UserInfo" is not always empty, sometime are correct...but it gone offline and notify GateUserNotReady.
Logged
Pages: [1] 2 3
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.03 seconds with 16 queries.