Skip to main content
The client bundles the real SmartFoxServer 2X SDK but never actually uses its socket layer. Every byte on the wire is written by a hand-rolled reimplementation that only reuses SFS2X’s data model, and the “encryption” bit is a length-derived XOR, not a cipher.

Transport

Plain TCP socket, no TLS. Host/port/zone/connection-type arrive dynamically from the GSL response. Two connection types exist:
  • connectionType 0: raw TCP, straight into the packet framing below.
  • connectionType 1: a one-shot literal HTTP/1.1 Upgrade: websocket preamble is sent first, purely to satisfy load balancers that require a valid HTTP handshake, then the exact same raw SFS2X binary framing runs on the same socket. This is not a real WebSocket: there’s no RFC 6455 frame masking anywhere in the read/write path. A Go client can dial TCP directly, or replay the literal handshake bytes if a load balancer demands them.
The 1.0.364 preamble is fixed (NetHandShakeInterceptor in BaseUtils; static-analysis-only):
  • Sec-WebSocket-Key: cmFuZG9t, which is base64 for random, on every connection.
  • User-Agent: LastWarWebSocket, plus fixed Cache-Control, Pragma, Accept-Encoding, TE, and Content-Length headers.
  • The request path comes from the ws://host/path line URL and defaults to /.
  • The client accepts the response on status 101, any 2xx, or 304. It never checks Sec-WebSocket-Accept.
  • On these lines the first ping is a plain ping, not the a=29 probe described below.
In 1.0.364, client_config switch 26 selects connection type 1 to the ws_ip host on port 80, and switch 44 makes every second connect retry use it (see Server-controlled transport switches). KCPMode is always "0", and the game socket never uses UDP; only the real-time PvP mini-games do, over a separate transport (see Mini-game PvP transport). Sockets set NoDelay, a 2 MiB receive buffer, a 64 KiB send buffer, and 30 s send and receive timeouts (static-analysis-only).

Gateway race and the pre-login probe

The GSL serverList[].ip field is a |-delimited list of gateway hosts for one zone, all on the same port. Two live GSL responses on 2026-10-04 listed the same three hostnames, with only the port differing by zone: 10783 for APS783 and 10072 for a guest account on APS72 (confirmed live):
The Lua also carries two fallback “proxy lines”, ProxyList in Global/EnumType.lua, named aws and cf by ProxyName. They use the zone’s current GameServerPort, the C# reads them through CSharpCallLuaInterface.GetAllProxy(), and the in-game ping screen lists them. When C# switches to them wasn’t traced (static-analysis-only):
A related helper, CommonUtil.GetPortId(zoneId), returns 17000 + zoneId. A packet capture only shows the addresses these resolve to, so a session config written by pcap -session-out holds IP addresses; the hostnames work in its ip field too. The shipped client connects to all the gateways at once and keeps whichever answers first. This comes from the 1.0.364 C# (ChooseLine, NetRawProxy) and matches the 2026-10-04 capture of the real iOS app:
  1. Open a TCP connection to every gateway in parallel.
  2. On each, immediately send a CustomPingPong request (c=0, a=29).
  3. The first gateway to answer with a pong wins. Close the others and save the winner as SERVER_IP.
  4. Only then send Login.
The capture showed the race across three gateways, two IPv4 and one Cloudflare IPv6: The three pongs carried serverTime values within 11 ms of each other, so all three front-ends reach one backend. The winner varies from run to run; an earlier capture had the pinned address winning. The probe’s p object is fixed: a masked, Android-login-shaped template with literal placeholder values, into which the client splices only the device’s real deviceId, plus a clientTime. It’s byte-identical across all three sockets apart from clientTime. Its purpose is unknown, and it may be an anti-fraud surface, so it’s documented here as a protocol fact only. The reply is a plain pong, {p:{serverTime, clientTime}} with serverTime in ms. After the probe, every keepalive is a plain ping. Per the C#, a gateway that times out at Login (7 s) is blacklisted and the connect is retried. A separate NetLineSpeedTester re-probes every gateway the same way for analytics, at most once per 25 s, and never switches lines (static-analysis-only). goclient doesn’t race. DoCrossServerLogin dials the | list in order, 10 s per host and IPv6-safe, sends no probe, and sends Login straight after connecting. The server accepts that order (confirmed live). The fallback is confirmed live too: with an unreachable TEST-NET address first in the list, the dial timed out after 10 s and the login went through on the next gateway. When goclient writes a changed address or token back to the session config, it keeps the list as long as the gateway it reached is on it.

Packet envelope: three nested layers

For every gameplay cmd, the "p" content is itself another SFSObject:
So a full mail.read request is schematically {c:1, a:13, p:{c:"mail.read", r:-1, p:{uid:..., type:..., toUser:..., _id:42}}}. The real client puts _id on every extension request: Login carries 1, and requests count up from 2. The server echoes _id and adds _time (observed in the 2026-10-04 capture). goclient does the same: _id on every extension request. An older goclient set it only on Login and login.init, and the server accepted that (confirmed live). Since the 1.0.370 fixes it also pairs each reply with its request by the echoed _id, as the client reads it off every reply (Assembly-CSharp.decompiled.cs:82052-82056), so a late reply to a request whose wait timed out is not taken for the next request of the same command (static-analysis-only).

Packet header bits

Send and receive framing differ

The 1.0.370 client, like 1.0.364, writes and reads packets with two different classes (static-analysis-only):
  • Send always uses the legacy NetPacket: header 0x80 | 0x40, plus 0x20 with zlib when the uncompressed body is over 1024 bytes, plus 0x08 when it’s over 65535, plus 0x04 and the server id when forwarding. The body is XORed against the little-endian bytes of its final length. The maximum is 1,000,000 bytes.
  • Receive uses NetPacketNew: when 0x20 and 0x10 are both set, the 4-byte uncompressed length follows, and the body is Zstd-decompressed. When only 0x20 is set, it’s zlib.
Since the 1.0.370 fixes goclient’s packet.go matches both sides: the big-size flag follows the uncompressed length, a body over 1,000,000 bytes is refused, and a body that compression would push past a 2-byte length is an error rather than a wrapped length.
The “encryption” is not encryption
The XOR keystream is derived entirely from the packet’s own (cleartext) length field. No secret material, no negotiation, no per-session state. This is obfuscation, not confidentiality, and needs zero cryptographic material to implement in Go, just XOR the body against the little-endian length, computed after compression.

SFSObject binary format

Big-endian throughout. A standalone serialized object is self-describing, it starts with its own tag byte and count. BIG_NUM, present in some SFS2X SDK builds, doesn’t exist in this game’s enum at all, no gap in the numbering. Not needed.

Which SDK is the reference

The APK carries two SFS2X C# libraries, and only one of them is live in 1.0.364 (static-analysis-only):
  • SmartFox2X is the official SFS2X C# API 1.7.8. The game uses its data model, binary codec, and request envelopes (ExtensionRequest, LoginRequest, LogoutRequest), but never constructs its socket stack.
  • BaseUtils holds the game’s own socket layer and framing (NetConnection, NetPacket for sending, NetPacketNew for receiving), which replaces SFS2X’s BitSwarm. There’s no BitSwarmManager anywhere on the shipping path.
  • Smartfox2xLw is a 2024 in-house fork of SmartFox2X stripped down to a codec. It’s dead code: the only reference to it is a placeholder field that’s never assigned, and its system controller has an empty handler table, so it can’t even process Login. Earlier versions of this page cited it; the citations now point at SmartFox2X and BaseUtils.
noUpdateAssemblies.json pins SmartFox2X to the APK copy, so the codec changes only with an app release, unless a hot update replaces that pin list. BaseUtils, which writes the actual frames, can still be replaced through a hot update.

Validated against the official client: sfs2x-api (npm)

SmartFoxServer publishes its own JS client SDK (npm install sfs2x-api, the official reference implementation, not a third-party reimplementation). Pulling it and diffing its packet/codec internals against everything above turned into a genuinely useful correctness check:
Checked against the official SDKResult
SFSObject type tags (0 NULL … 20 TEXT, full range)Exact match
Envelope shape {c: BYTE, a: SHORT, p: SFS_OBJECT}Exact match
Action ids: Login=1, PingPong=29Exact match
zlib compression, header bits 0x80/0x20/0x08Exact match
bigSized threshold specificallyCorrection, not a match: the JS SDK’s own IoHandler.onPacketWrite uses 65335, which this dossier briefly (and wrongly) adopted as a “fix.” The actual references for this game are the SmartFox2X 1.7.8 C# SDK it embeds (SmartFox2X.decompiled.cs:31762-31783) and its own BaseUtils sender (BaseUtils.decompiled.cs:33284-33324), which both use the standard 65535. The JS client’s 65335 is an idiosyncratic quirk of that specific (different) implementation, not a shared protocol constant. Reverted after a later audit pass caught the discrepancy; a good reminder that “official” only means authoritative for the exact client it ships with.
Encryption flag (0x40) / XOR obfuscationRefined, the bit itself is real vanilla SFS2X: the C# SDK sets it exactly when a CryptoKey (a real AES-CBC key+IV pair) is present (SmartFox2X.decompiled.cs:31766). In stock SFS2X that key comes from an HTTPS call to /BlueBox/CryptoManager (SmartFox2X.decompiled.cs:20760-20836), not from the Handshake. This game never fetches a CryptoKey at all, yet the client always sets 0x40 anyway and the server expects the length-derived XOR instead of real AES, a deliberate override of the vanilla semantics, not evidence the bit is undocumented. The server’s own frames don’t set it (2026-10-04 capture). The JS SDK’s read/write path (which never sets or checks this bit) simply never implements the CryptoKey path at all, consistent with this reading.
0x10 LZ4-repurposed-as-Zstandard flagGame-specific meaning, stock bit: in the C# SDK, header bit 0x10 is BlueBoxed (HTTP tunnelling; SmartFox2X.decompiled.cs:31328-31331), and the game’s own old header class still calls it that (BaseUtils.decompiled.cs:33142-33175). The game repurposes it on receive to mean Zstandard, under the name useLZ4. The JS SDK doesn’t use it
The official SDK’s connection sequence also revealed a real gap: it sends a Handshake request (action 0, fields api/cl, a step this dossier previously called out below as unused) before every Login, receiving back a session token / max-message-size / compression-threshold. Sending it against this game’s real server got a clean, correctly-shaped response, {ct=3072, ms=1000000, tk=<32-hex>}, so the server-side handshake handler is real and working, even though the shipped client never uses it (see below). Practically, though, adding it to the Go client changed nothing: at the time this was tested, the init-push and reconnect-block problems were still unresolved, and this Handshake step made no difference to either, guest login and email-bind behaved identically with or without it. Both problems have since been resolved by unrelated fixes (a Zstd decompression bug and a token-identity mismatch, respectively, see Live validation against production), confirming the Handshake step was never the missing piece.

Heartbeat & reconnect

A PingPongRequest (system controller, action 29) fires every 4000 ms. On the wire, the real client nests its clientTime one level deeper than the action’s own p: {c:0, a:29, p:{p:{clientTime}}} (observed in the 2026-10-04 capture). goclient sent it flat, p:{clientTime}, until 2026-11-04, and the server answered that too (confirmed live). But those pongs never synced the server clock: a live run of main c00d1c5 logged no offset. goclient now nests it like the client, and the first live run with that synced from the first pong (offset 24 ms, round trip 118 ms, confirmed live 2026-11-04). The pong carries serverTime in ms and echoes clientTime; the client uses the pair for server-time sync. In the capture, the server answered all 83 heartbeats over 320 s. The client’s sync (Timer.SyncServerTime) takes the round trip as the pong’s arrival minus clientTime. It keeps the pong with the shortest round trip, or any under 200 ms, and sets server time to serverTime plus half the round trip, running on from there with a monotonic timer. goclient keeps the same clock per connection (GameConn.ServerNow) and logs server clock: offsetMs … (server time minus host time, the round trip of the sample in use and the pong count) when the connection closes, as a Warn from 2 s off. Every time gate in the features and the core collect reads that clock, as do the two game times goclient sends, al.help.all’s cmdBaseTime and the fireworks scan’s timeStamp, which the client fills with its server time. Before the first pong they read the host clock (static-analysis-only). Client-perceived timeout is 12s since the last pong or response, at which point the client disconnects and re-runs the entire connect→login sequence; there is no lightweight session-resume. No exponential backoff was found; retry cadence is a fixed timer. The 1.0.364 timers (static-analysis-only): goclient sends its first heartbeat as soon as it connects, waits up to 45 s for init, and makes a single attempt. That’s more conservative than the real client, and the server accepts it. Since the 1.0.370 fixes, once the server has answered a ping, waits that end with no frame at all end the run as a dead connection when their silence adds up to more than 12 s (the end of the second silent 8 s wait in a row, about 16 s; a single longer wait, such as the one for init, can pass it alone), after the client’s receive timeout (BaseUtils.decompiled.cs:35935, 36017-36031; static-analysis-only).

Error conventions

Errors on extension responses are per handler; the 1.0.370 Lua, like 1.0.364, has no generic error layer (static-analysis-only):
  • A failed request carries errorCode, a UtfString holding either an error code or a locale key.
  • An optional errorPara2 (UtfStringArray) carries tip parameters. The client shows Localization:GetString(errorCode, table.unpack(errorPara2)).
  • E000000 is the generic “unknown error” (SeverErrorCode in ConstDefine.lua). A few handlers treat it as a soft “no data” result, for example a rank preview with nothing to rank.
  • Login rejections don’t use errorCode. They arrive as SFS2X’s own ec (a short) and ep (a UTF string array), formatted through the stock SFS2X error table. Code 28 is that table’s "{0}" passthrough, which carries the game’s E0xx strings, or a numeric code such as a ban’s 4;…, in ep[0], see Identity, login & session.
  • Fatal conditions: a Login rejection, push.user.off (kicked: the client quits and doesn’t reconnect) and init.error come from the C#; push.server.stop (PushServerStopMessage.lua:8-12) is Lua; and connection loss. push.server.tostop is only a countdown toast (PushServerToStopMessage.lua:9-33). Three more Lua pushes end the session: push.user.gm.off always (PushUserGMOffMessage.lua:9-16), push.refund.restart without an errorCode (PushRefundRestartMessage.lua:8-27), and push.account.device.del when it names this device (PushAccountDeviceDelMessage.lua:8-25). goclient exits 3 on the first two and 2 on the device removal.

Server-controlled transport switches

The check-version response’s client_config field is a |-separated list of "0"/"1" flags, indexed by switch id (ClientSwitch.Parse, see Startup, version-check & hot-update). In 1.0.370, as in 1.0.364, these switches change what goes on the wire (static-analysis-only): The forward bit in the 2026-10-04 capture suggests switch 29 is on for the iOS app today; the server still accepts goclient’s frames without it. goclient doesn’t parse client_config.
Settled: the shipped client never sends a HandshakeSFS2X’s SDK ships a full Handshake request (session token negotiation), an AES CryptoKey path (DefaultPacketEncrypter, keyed over HTTPS from /BlueBox/CryptoManager), and a complete MMORoom/AOI (area-of-interest) streaming subsystem. The game uses none of them. The embedded SmartFox2X SDK contains a working Handshake (SendHandshakeRequest, SmartFox2X.decompiled.cs:20085-20089), and the live server answers it when sent (see above), but the game’s own transport never calls it. In 1.0.364, NetConnection handles only two system actions, a=1 (Login) and a=29 (ping-pong), and the connect path runs TCP connect, a=29 probe, then Login (static-analysis-only). The 2026-10-04 capture of the real iOS app agrees: no a=0 on any of the three sockets. A reimplementation should skip it; goclient keeps -handshake only as an off-by-default experiment. Instead of SFS2X’s AOI streaming, the client pulls the world-map viewport and individual points with its own extension requests (see World map).

Mini-game PvP transport

Two real-time PvP mini-games, BiuBiu (shooting) and GGGo, don’t run over the game socket. They use the Joker.Share assembly (static-analysis-only):
  1. Matchmaking runs over ordinary SFS2X commands (activity.shoot.pvp.*). The reply names a separate server: ip, port, sessionidgame, and sessionidplayer, a shape that looks like AWS GameLift.
  2. The client connects there over TCP, or in “Hybrid” mode over TCP plus UDP.
  3. TCP frames are u32 LE length | i32 opcode | i32 jsonLen | JSON.
  4. UDP datagrams start with KCPH and a channel id, and use kcp2k-style Connect, Data, and Disconnect messages, with an MTU of 470.
This is recorded as a transport fact only. Results in these modes are client-computed, and forging them is out of scope (see Military, hero & battle).