Closed meytotr closed 1 year ago
Hi 👋 In the server try using socket version <= 4.2.0, I didn’t test it in newer versions
On Wed, 20 Jul 2022 at 12:26, meytotr @.***> wrote:
im trying use glitch.com server... localhost work but not work for myurl.glitch.me
— Reply to this email directly, view it on GitHub https://github.com/itisnajim/SocketIOUnity/issues/22, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKS3NIWBOCR4DWJHZBL35RLVU7O6XANCNFSM54DIY7XA . You are receiving this because you are subscribed to this thread.Message ID: @.***>
--
i did try 2-3-4 all of them.. maybe i dont know how can i have to use it... i have to use ws://, wss:// or still https:// ??? u can try it fastly.. can u try? just copy ur test server and try it on glitch 🙏 i have 1 socket.io for unity but its working with socket io 2v.. its bad :(
you have to make it accessible from outside of the network (the host/glitch), !
const port = 11100// or process.env.PORT || 11100;
const app = require('express')();
const socket = require('socket.io');
const server = app.listen(port, '0.0.0.0', () => { // 0.0.0.0 instead of localhost !
console.log('Listening on port '+port);
});
var io = socket(server, {
pingInterval: 5000,
pingTimeout: 3000,
});
...
give this a try
not worked !
its not about server i think..
because its working on localhost server..
var uri = new Uri("http://192.168.1.107:11100");
but if change it for remote server..
var uri = new Uri("https://***.glitch.me");
not work anymore..
i did try express on server not worked.. i did try on client.cs
var uri = new Uri("wss://192.168.1.107:11100"); or ws:// not worked too..
did u never try on remote server?? not just glitch.. can u share server and client code for this remote tried.. its not only about server i thinkk.. i did use https://github.com/fpanettieri/unity-socket.io-DEPRECATED i dont want to use this.. because its work for socket io v2.1.1
its work for connect with ws:// but urs??? not work for remote server.. urs working on local server soo gooodd..
Yes I tried it on a remote server ( digitalocean ) and it's working, but not glitch, I used the same code above, should be accessible using the 0.0.0.0 (this network) instead of localhost. So make sure its 0.0.0.0
Add the line below app.get('/check', (req, res) => res.send('Hello World'))
Then check if xxxx.glitch.me/check showing the 'Hello Wold' This to make sure your setup its ✅
If not working, I'll do a test for you this night ☺️
i changed port 11100 to 3000 and saw the Hello World on ../check but still not work for unity..
Soooo thanx for help.. I will waiting for it
https://amritb.github.io/socketio-client-tool/v1/
i did try this tool.. and its work for it.. just i cant work with urs :( if u can do.. can u send me both codes.. on unity-client and server
my project on glitch take forever to start, my App Status its Ok, so idk, maybe i have to wait more, git repo, glitch.me link: https://trusted-carbonated-divan.glitch.me/check
What platform did you test your Unity app on? if mobile, then check in pc/mac,
In the mobile platform, you may have one of the issue declared here: https://github.com/itisnajim/SocketIOUnity/issues/19 https://github.com/itisnajim/SocketIOUnity/issues/12 https://github.com/itisnajim/SocketIOUnity/issues/4
i said before :) ur port have to be 3000 on glitch.. change port 3000 and it will work.
but my problem not on server man.. its about client.. change ur port 3000 and try for unity again please... and its not about my device too.. its not working on Unity editor too.. im using this now.. for client side https://github.com/fpanettieri/unity-socket.io-DEPRECATED but its only for socketio version 2 i did remix ur glitch project and change port 11100 to 3000 and its work for /check page... but please look ur unity client side i need it. i cant connect remote. if im not using glitch.. if starting server on my localhost ur project work on it.. but remote... the glitch.... not working..this is the problem.. problem is new Uri(....)
I got it working on Heroku. Took me sometime but it is working. I will test on android and iOS too and update here. Successfully connected from unity editor.
`const express = require('express'); const path = require('path');
const app = express();
let rooms = [];
/SERVER/ const port = process.env.PORT || 5000; server = app.listen(port, function () { console.log('App is listening on port ' + port) });
/SOCKET.IO/ const socket = require('socket.io'); io = socket(server);
io.on('connection', (socket) => { //bunch of functionality })`
Update: working on android. Had to change these settings build and run -> player settings -> player -> Other settings -> Configuration to select IL2CPP as a Scripting Backend, and .NET 4.x as API Compatibility Settings, Also I had to change internet access to require. Tested on: oppo A54 Server hosted on: Heroku Will test on iOS and update tomorrow.
I got it working on Heroku. Took me sometime but it is working. I will test on android and iOS too and update here. Successfully connected from unity editor.
`const express = require('express'); const path = require('path');
const app = express();
let rooms = [];
/SERVER/ const port = process.env.PORT || 5000; server = app.listen(port, function () { console.log('App is listening on port ' + port) });
/SOCKET.IO/ const socket = require('socket.io'); io = socket(server);
io.on('connection', (socket) => { //bunch of functionality })`
dude i need unity side code.. server is ok.. i need new Uri(...) how did u do it. can u share ur connect part ur client
var uri = new Uri("https://www.example.com");
public class SocketManager : MonoBehaviour
{
...
public static SocketIOUnity socket = null;
void Start() // or Awake()
{
if(SocketManager.socket == null){ // or if(!SocketManager.socket)
StartSocketConnection();
DontDestroyOnLoad(transform.root.gameObject);
}
}
void StartSocketConnection()
{
var uri = new Uri("https://example.com");
SocketManager.socket = new SocketIOUnity( ...
...
}
...
var uri = new Uri("https://www.example.com");
public class SocketManager : MonoBehaviour { ... public static SocketIOUnity socket = null; void Start() // or Awake() { if(SocketManager.socket == null){ // or if(!SocketManager.socket) StartSocketConnection(); DontDestroyOnLoad(transform.root.gameObject); } } void StartSocketConnection() { var uri = new Uri("https://example.com"); SocketManager.socket = new SocketIOUnity( ... ... } ...
Its like in ur project example.. i did it already.. but not work glitch.. did u change ur port 11100 to 3000.. u can try it for ur client.. on unity editor.. we dont need build right??
im using ur example client and ur glitch example server
i check for android logcat.. this is try reconnect logs.. what is wrong for connect..
2022.07.26 22:18:33.861 32102 32587 Info Unity 26.07.2022 22:18:33 Reconnecting: attempt = 2
2022.07.26 22:18:33.861 32102 32587 Info Unity UnityEngine.Logger:Log(LogType, Object)
2022.07.26 22:18:33.861 32102 32587 Info Unity <>c:
2022.07.26 22:18:33.861 32102 32587 Info Unity SocketIOClient.<
2022.07.26 22:18:33.861 32102 32587 Info Unity System.Threading.ContextCallback:Invoke(Object)
2022.07.26 22:18:33.861 32102 32587 Info Unity System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean)
2022.07.26 22:18:33.861 32102 32587 Info Unity System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object, Boolean)
2022.07.26 22:18:33.861 32102 32587 Info Unity System.Runtime.CompilerServices.MoveNextRunner:Run()
2022.07.26 22:18:33.861 32102 32587 Info Unity System.Action:Invoke()
2022.07.26 22:18:33.861 32102 32587 Info Unity System.Threading.Tasks.AwaitTaskContinuation:RunOrScheduleAction(Action, Boolean, Task&)
2022.07.26 22:18:33.861 32102 32587 Info Unity System.Threading.Tasks.Task:FinishContinuations()
2022.07.26 22:18:33.861 32102 32587 Info Unity System.Threading.Tasks.Task`1:TrySetResult(TResult) 2022.07.26 22:18:33.861 32102 32587 Info Unity System.Threading.Tasks.DelayPromise:Complete() 2022.07.26 22:18:33.861 32102 32587 Info Unity System.Threading.TimerCallback:Invoke(Object) 2022.07.26 22:18:33.861 32102 32587 Info Unity System.Threading.WaitCallback:Invoke(Object) 2022.07.26 22:18:33.861 32102 32587 Info Unity System.Threading.ThreadPoolWorkQueue:Dispatch()
Also experiencing similar issues. Locally it works ( with remove server in heroku ) But on my android device it doest. I do get the connection socket working but anything i emit does not work
Also experiencing similar issues. Locally it works ( with remove server in heroku ) But on my android device it doest. I do get the connection socket working but anything i emit does not work
can u share ur unity code for connect.. my connection socket not work either. maybe i can do it.. i think my mistake with uri code.. new Uri(....).. can u share these
IL2CPP Code Generation to Faster (smaller) builds in build settings fixed for me on IOS builds
im trying use glitch.com server... localhost work but not work for myurl.glitch.me