[SFS - ERROR] [TCPSocketLayer] Connection closed by the remote side

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

Dzxyan
Posts: 7
Joined: 11 May 2016, 09:27

[SFS - ERROR] [TCPSocketLayer] Connection closed by the remote side

Postby Dzxyan » 11 May 2016, 09:28

One of my client receive [SFS - ERROR] [TCPSocketLayer] Connection closed by the remote side
when he try connect to zone,
most of my clients didn't have such issue,
anyone can help me?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: [SFS - ERROR] [TCPSocketLayer] Connection closed by the remote side

Postby Lapo » 11 May 2016, 13:55

Hi,
I need more details to understand.
Is the client able to connect to the server at all? Or does he receive a CONNECTION event with the "success" parameter set to false?

Does your application allow using the BlueBox (HTTP tunnelling), if not I'd recommend enabling it from the client configuration so that users behind a firewall can have better chances of connecting to SmartFoxServer.

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
Dzxyan
Posts: 7
Joined: 11 May 2016, 09:27

Re: [SFS - ERROR] [TCPSocketLayer] Connection closed by the remote side

Postby Dzxyan » 12 May 2016, 03:16

one of my client have connection successful
but when client request StartCoroutine(_sfs.InitCrypto());
server return [SFS - ERROR] [TCPSocketLayer] Connection closed by the remote side
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: [SFS - ERROR] [TCPSocketLayer] Connection closed by the remote side

Postby Lapo » 12 May 2016, 08:05

So you're using encryption?
Can you show us the code you're using for connecting and logging in?

Also I need to see the DEBUG transcript from the Unity console, so that we can see what goes between client and server and the full details of the exception.

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
Dzxyan
Posts: 7
Joined: 11 May 2016, 09:27

Re: [SFS - ERROR] [TCPSocketLayer] Connection closed by the remote side

Postby Dzxyan » 12 May 2016, 11:51

Code: Select all

 public void Connect()
    {
            ConfigData cfg = SmartFoxConnectionSettings.Cfg;
            _sfs.Connect(cfg);
   }

    //----------------------------------------------------------
    // Handle connection response from server
    //----------------------------------------------------------
    public void OnConnection(BaseEvent evt)
    {
        SmartFoxConnectionSettings.ConnectionSuccess = (bool) evt.Params["success"];
        if (SmartFoxConnectionSettings.ConnectionSuccess)
        {
            Debug.Log("Connection successful!");

                StartCoroutine(_sfs.InitCrypto());
           
        }
        else
        {
            _sfs = new SmartFox(true);
            _sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection);
            _sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
            _sfs.AddEventListener(SFSEvent.LOGIN, OnLogin);
            _sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError);
            _sfs.AddEventListener(SFSEvent.LOGOUT, OnLogout);
            _sfs.AddEventListener(SFSEvent.ROOM_JOIN, OnJoinRoom);
            _sfs.AddEventListener(SFSEvent.EXTENSION_RESPONSE, onExtensionResponse);
            _sfs.AddEventListener(SFSEvent.CONNECTION_RESUME, OnConnectionResume);
            _sfs.AddEventListener(SFSEvent.CONNECTION_RETRY, OnConnectionRetry);
            _sfs.AddEventListener(SFSEvent.CRYPTO_INIT, OnEncryptionInitialized);
         
            // Also register for all debug messages from the API at the given log level
            _sfs.AddLogListener(logLevel, OnDebugMessage);

            Debug.Log("Not connected (client API v" + _sfs.Version + ")");
        }
    }

    public void OnEncryptionInitialized(BaseEvent evt)
    {
        if ((bool) evt.Params["success"])
        {
            // Do login
            SmartFoxServer._sfs.Send(new LoginRequest(accountId, accountPassword, zone));
        }
        else
        {
            _sfs = new SmartFox(true);
            _sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection);
            _sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
            _sfs.AddEventListener(SFSEvent.LOGIN, OnLogin);
            _sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError);
            _sfs.AddEventListener(SFSEvent.LOGOUT, OnLogout);
            _sfs.AddEventListener(SFSEvent.ROOM_JOIN, OnJoinRoom);
            _sfs.AddEventListener(SFSEvent.EXTENSION_RESPONSE, onExtensionResponse);
            _sfs.AddEventListener(SFSEvent.CONNECTION_RESUME, OnConnectionResume);
            _sfs.AddEventListener(SFSEvent.CONNECTION_RETRY, OnConnectionRetry);
            _sfs.AddEventListener(SFSEvent.CRYPTO_INIT, OnEncryptionInitialized);

            // Also register for all debug messages from the API at the given log level
            _sfs.AddLogListener(logLevel, OnDebugMessage);


            Debug.Log((string) evt.Params["errorMessage"]);
            Debug.Log("Not connected (client API v" + _sfs.Version + ")");
        }
    }


My client can connect to smartfox, but when fire login request didn't recieve by server.
User avatar
Bax
Site Admin
Posts: 4609
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: [SFS - ERROR] [TCPSocketLayer] Connection closed by the remote side

Postby Bax » 12 May 2016, 13:59

Your code is not working because you are adding the listeners (including the SFSEvent.CONNECTION listener) in the SFSEvent.CONNECTION listener itself. This will never be called.
I suggest to take a look at the "Advanced Connector" example in the Unity 5 examples package available here: http://smartfoxserver.com/download/sfs2x#p=examples
It shows how to deal with the whole connection process, including encryption initialization and login. You can strip the "webgl" related parts (see the conditional compilation instructions) if not needed.
Paolo Bax
The SmartFoxServer Team
Dzxyan
Posts: 7
Joined: 11 May 2016, 09:27

Re: [SFS - ERROR] [TCPSocketLayer] Connection closed by the remote side

Postby Dzxyan » 13 May 2016, 03:24

Thanks man, i will try and see
Dzxyan
Posts: 7
Joined: 11 May 2016, 09:27

Re: [SFS - ERROR] [TCPSocketLayer] Connection closed by the remote side

Postby Dzxyan » 13 May 2016, 05:36

I have a problem for my editor,
every time stop my editor will freeze my editor
i follow what new advanced connection that you share to me,
and for windows standalone crash when quit application problem can't fixed?
User avatar
Bax
Site Admin
Posts: 4609
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: [SFS - ERROR] [TCPSocketLayer] Connection closed by the remote side

Postby Bax » 13 May 2016, 07:22

We tested that example in Windows standalone too, and didn't figure any crash.
Can you provide more information?
Paolo Bax
The SmartFoxServer Team
chocolateboy
Posts: 1
Joined: 18 Apr 2017, 06:13

Re: [SFS - ERROR] [TCPSocketLayer] Connection closed by the remote side

Postby chocolateboy » 18 Apr 2017, 18:04

Hi There,
I am facing same issue can anyone help me on that
User avatar
Bax
Site Admin
Posts: 4609
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: [SFS - ERROR] [TCPSocketLayer] Connection closed by the remote side

Postby Bax » 19 Apr 2017, 11:26

We never got a reply to our message.
If you can share more information on the issue and the steps to reproduce it, we will be glad to help.
Paolo Bax
The SmartFoxServer Team
draxthis
Posts: 2
Joined: 30 Aug 2017, 14:49

Re: [SFS - ERROR] [TCPSocketLayer] Connection closed by the remote side

Postby draxthis » 30 Aug 2017, 15:20

Hello,
I see the last time this thread was posted to was April and I apologize if this is solved elsewhere but I am having trouble locating it.
I have installed the server on two different Linux machines to make sure I kept getting the same issue and I did.

I have followed the Unity tutorial for the Connector and I can connect with a connection return of success; however, after about 30 seconds, I receive the error message [SFS - ERROR] [TCPSocketLayer] Connection closed by the remote side. I am convinced I missed something somewhere that's causing this, either in the SFS setup or on my Linux box.

Any help or direction would be very much appreciated. If you need any additional information, please let me know.
User avatar
Bax
Site Admin
Posts: 4609
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: [SFS - ERROR] [TCPSocketLayer] Connection closed by the remote side

Postby Bax » 30 Aug 2017, 16:08

One of the server settings is the "Session maximum idle time": if, after a successful connection, you don't send a LoginRequest before that time has passed, the server will automatically disconnect the client.
So what you are experiencing is expected (unless you are already sending the Login request!).
Paolo Bax
The SmartFoxServer Team
draxthis
Posts: 2
Joined: 30 Aug 2017, 14:49

Re: [SFS - ERROR] [TCPSocketLayer] Connection closed by the remote side

Postby draxthis » 30 Aug 2017, 16:46

Wow, OK, I feel foolish. Let me just restate it here in case anyone else needs it and so I fully understand.

In the first tutorial for Unity, it is simply connecting to the server and nothing else. Even though you set the zone, you do not actually send any log in information, you are only connecting? Therefore, after the 30 seconds, which is equal to the Session maximum idle time on my server, it disconnects the client from the host side.

Thank you for the fast response.

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 35 guests