Problems in SocketWriter::UDP inner loop.

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

outreal
Posts: 2
Joined: 23 Nov 2020, 19:47

Problems in SocketWriter::UDP inner loop.

Postby outreal » 24 Dec 2020, 13:13

Hi all,

1 » SFS2X version is 2.16.3 (before patching it was 2.14)

2 » The client API is Unity3D API V1.7.12

3 » After patching SFS2X from 2.14 to 2.16.3 I have noticed in log files spammed warnings, which says Problems in SocketWriter::UDP inner loop. It doesn't cause problems, but I am afraid it will once we have more players on the server.

4 » It happens only in production

5 » It started happening after it was patched, which is around 2 days ago, but noticed only this morning.
Steps to reproduce:
1) Build a server side room extension, which sends extension response over UDP
2) Host sfs2x 2.16.3 on a cloud. Make sure the cloud has opened port 443 and ssl installed
3) In Unity make a code which send corresponding extension request to sfs server every second over UDP. Make sure the port connects to is 443
4) Host WebGL unity app on the same cloud in ROOT folder
5) Open the WebGL Unity App in the any browser
6) Open log monitor on the server and observe UDP inner loop.

6 » The logs has the same WARNING message repeated many times in either with no delays or 1 second delay:

Problems in SocketWriter::UDP inner loop.
java.lang.NullPointerException
at com.smartfoxserver.bitswarm.core.SocketWriterV3.udpSend(SocketWriterV3.java:515)
at com.smartfoxserver.bitswarm.core.SocketWriterV3.access$12(SocketWriterV3.java:484)
at com.smartfoxserver.bitswarm.core.SocketWriterV3$UDPWriteRunner.run(SocketWriterV3.java:868)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)


7 » N/A

8 »
Here is the client code, which sends data:

Code: Select all

if (Time.time > UDPSendAfter && isRequired || Time.time > ExtraUDPSendAfter) {
                UDPSendAfter = Time.time + UDPSendRate;
                ExtraUDPSendAfter = Time.time + 1f;
                ExtensionRequest request = new ExtensionRequest(SFSManager.SFScmdCharacterControllerName, GetSFSUserPos(), SFSManager.sfs.LastJoinedRoom, true);
                try
                {
                    SFSManager.sfs.Send(request);
                }
                catch (System.Exception)
                {
                    if(request == null) {
                        Debug.LogError("[SFSNetworkTransform] request is null");
                    } else if(SFSManager.sfs == null) {
                        Debug.LogError("[SFSNetworkTransform] sfs is null");
                    } else if(SFSManager.sfs.IsConnected == false) {
                        Debug.LogError("[SFSNetworkTransform] You are not connected");
                    } else if(SFSManager.sfs.UdpInited == false) {
                        Debug.LogError("[SFSNetworkTransform] UDP is not inited");
                    } else if(SFSManager.sfs.UdpAvailable == false) {
                        Debug.LogError("[SFSNetworkTransform] UDP is not available");
                    } else {
                        Debug.LogError("[SFSNetworkTransform] Unknown error");
                    }
                }
                lastSentRyOverUDP = transform.eulerAngles.y;
                lastSentPositionOverUDP = transform.position;
                UDPPacketsSentCount++;
}

public virtual SFSObject GetSFSUserPos() {
            sfsTransformData = new SFSObject();
            sfsTransformData.PutFloat("x", transform.position.x);
            sfsTransformData.PutFloat("y", transform.position.y);
            sfsTransformData.PutFloat("z", transform.position.z);
            sfsTransformData.PutFloat("ry", transform.eulerAngles.y);
            return sfsTransformData;
}


Here is the extension code, which broadcasts response to other users:

Code: Select all

public void handleClientRequest(User fromUser, ISFSObject data) {
   data.putLong("t", System.currentTimeMillis());
   data.putInt("id", fromUser.getId());
   this.send("characterController", data, UserHelper.getRecipientsList(RoomHelper.getCurrentRoom(this)), true);
}

9 » N/A

Regards,
Thedrhax14.
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Problems in SocketWriter::UDP inner loop.

Postby Lapo » 11 Jan 2021, 10:27

Hi,
for starters I apologize for the delay in responding. During the Xmas vacation the forum has received a lot of spam posts that pushed your request way down the list of new topics to moderate.
In other words our "moderation queue" was filled with over 150 posts and yours got unnoticed for a while. Again, I am sorry for the inconvenience.

2) Host sfs2x 2.16.3 on a cloud. Make sure the cloud has opened port 443 and ssl installed

Can you clarify why this is important?
Does the issue appear only if your use 443 and SSL?

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Problems in SocketWriter::UDP inner loop.

Postby Lapo » 11 Jan 2021, 10:36

Also, you mentioned WebGL as the build target for your Unity client.
WebGL uses Websocket as the communication protocol which is TCP only, therefore it's not possible to communicate using UDP with a WebGL client.

To use UDP you need to build your project for a native platform, such as Windows, MacOS, iOS, Android etc...

Hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 19 guests