I would like to share this here too. Because It is possible that other dependencies(like defold-websocket) or Defold’s cache may cause this problem:
I am just using default example. When server is not available, onError message “mostly” doesn’t triggered. Sometimes it works when I build and then rebuild the project, but I couldn’t find any clue or pattern about this. Its possible that other dependencies may cause this problem or maybe built in cache of Defold.
This is the client output when there isn’t any server and onError doesn’t triggered :
{
roomStates = {
}
roomsAvailableRequests = {
}
requestId = 0,
on = function: 0x0a1b70e0,
connection = {
emit = function: 0x0aaf9d60,
_enqueuedCalls = {
}
on = function: 0x0aaf9d80,
is_html5 = false,
off = function: 0x0aaf9f40,
_on = {
close = {
1 = function: 0x0aafa1f0,
}
error = {
1 = function: 0x0aafa140,
}
message = {
1 = function: 0x0aafa180,
}
open = {
1 = function: 0x0aafa0a0,
}
}
state = CLOSED,
listeners = function: 0x0aaf9d40,
endpoint = ws://localhost:8080/?colyseusid=xmjmMr3lo,
}
rooms = {
}
hostname = ws://localhost:8080/,
connectingRooms = {
}
_on = {
}
emit = function: 0x0a1b7210,
listeners = function: 0x0a1b71f0,
off = function: 0x0a1b7100,
id = xmjmMr3lo,
}
There isn’t any server and onError triggered :
{
roomStates = {
}
roomsAvailableRequests = {
}
requestId = 0,
on = function: 0x12f4f0e0,
connection = {
ws = {
step = function: 0x13892d10,
sock_close = function: 0x13892860,
on_close = function: 0x13892880,
send = function: 0x13892c30,
on_disconnected = function: 0x13892d70,
sock = tcp{client}: 0x13893630,
sock_send = function: 0x138928a0,
close = function: 0x13892cc0,
on_connected = function: 0x13892d50,
on_message = function: 0x13892d30,
connect = function: 0x138929f0,
state = CLOSED,
sock_connect = function: 0x13892830,
sock_receive = function: 0x138928c0,
receive = function: 0x13892c80,
}
emit = function: 0x13891d60,
_enqueuedCalls = {
}
on = function: 0x13891d80,
is_html5 = false,
off = function: 0x13891f40,
_on = {
close = {
1 = function: 0x138921f0,
}
error = {
1 = function: 0x13892140,
}
message = {
1 = function: 0x13892180,
}
open = {
1 = function: 0x138920a0,
}
}
state = CONNECTING,
listeners = function: 0x13891d40,
endpoint = ws://localhost:8080/?colyseusid=xmjmMr3lo,
}
rooms = {
}
hostname = ws://localhost:8080/,
connectingRooms = {
}
_on = {
}
emit = function: 0x12f4f210,
listeners = function: 0x12f4f1f0,
off = function: 0x12f4f100,
id = xmjmMr3lo,
}