how to use unity and websockets - node.js

Hey guys I'm making a unity webGL build with websocketsharp, https://github.com/sta/websocket-sharp
Weird thing is it works fine when I run it from client, I can send and receive messages with nodeJS but when I upload the build to my server I get this error when I try to connect to the server
12/5/2021 6:53:40 PM|Fatal|.|System.Net.Sockets.SocketException (0x80004005): Could not resolve host 'mydomain.io'
Desktop.loader.js:1 at System.Net.Dns.Error_11001 (System.String hostName) [0x00000] in <00000000000000000000000000000000>:0
here is how I am connecting in C#
ws = new WebSocket("wss://mydomain.io:8000");
ws.SetProxy("https://mydomain.io/server", "", "");
I have no idea how to debug this. Why would it work in the unity editor but not when I upload to the server? Is websocketssharp the best way to communicate with a nodeJS server?

As far as I understand in general WebSocket and networking .Net / c# classes are not supported in WebGL. You would need to either do the networking on JavaScript side or use UnityWebRequest.
In particular from the linked asset you are using
It works with Unity Free, but there are some limitations:
Security Sandbox of the Webplayer (The server is not available in Web Player)
WebGL Networking (Not available in WebGL)
Why would it work in the unity editor but not when I upload to the server?
-> Because within the Unity Editor you are still executing the pre-compiled .Net code on your standalone PC where these classes are fully supported. It isn't compiled into WebGL until you actually build your project.

Related

IIS/ASP.Net vs NodeJs/ExpressJS

I'm very new to NodeJs/expressJs, i read tons of articles on internet and still don't understand it
is NodeJs a web server like IIS ? if so can i host an asp.net app in NodeJS ?
Is expressJs a framework like ASP.NET ?
I currently work on both IIS ASP.NET applications as well as NodeJS/ExpressJS systems and the below is what I have noted to be different:
IIS:
Windows server based
Can have strict setups such as MVC etc
Built in deployment that compiles the entire website
Setup can take quite some time to create all modals and get all
plugins working etc
Services can take some time setup and modal mapping can be tedious
NodeJS/ExpressJS:
Not Windows based. I run this typically on an Ubuntu server with
Nginx to push the domain to the public
Easy to setup and fast to get something basic online
Does not natively compile and runs files as they are
Uses npm package manager with easy to install packages
Does not have strict setups but you can technically create your own
MVC style system
Code can quickly become messy however with the correct approach you
can manage the amount of code easily.
NodeJS is not a web server. It is a backend server (Such as a REST API etc)
ExpressJS sits ontop of NodeJS to add functionality and is essentially a framework. Coupled with jade/pug you can write js inside the html.

how can i track my mobile app user when the app is killed

i want to implement tracking in my app but i am confused on how to get the location from the app if the app is not opened and send it to the server i tried socket , GPS-tracking but it did not work.
can any one guide me to how this is implemented and any resources or libraries to use ?
For Android projects React Native includes headless JS that does just what you are asking.
iOS is more complicated but the best solution I've found is a package called React Native Background Geolocation
Unfortunately this is not possible in a PWA without a plugin due to W3C's and Jake Archibald's refusal to implement the TravelManager detailed here
If the TravelManager were to be implemented a ServiceWorker intance would be automatically spun up on change of location in order to foreground your Web App or instantiate a new instance.

Node JS web application to LAN application( Desktop App)

I am very new to Node JS. recently developed a web application in NodeJS & hosted it on a common server along with Database for a clinical management.
Now I have an immediate requirement of making it as a desktop application so that users in a clinic can run the exe on their desktop and the application where its installed will create a database for other users to connect and make their updates.
Checked articles with Electron, node-webkit but didn't work for my current solution.
Is there any other alternative solution where I can make it as a desktop for Windows and Mac. Seeking your kind help !!!
There is the software NEXE which shows promising results however, when it comes down too it, Node.JS is a perfectly fine platform for production environments and is quite performant for the use-case you suggest. You can bundle a Node.JS installation and call upon it from your C code using system, exec or spawn calls. You can also open your favourite browser from the command line, while Google Chrome has the --kiosk flag to show in widescreen by default.
Just some ideas.

Nodejs OLE-COM server

I am using win32ole to access COM-OLE (automation) bindings inside a windows PC such as excel, word etc.
Now what I want is to implement a COM-OLE server using nodejs. I can't seem to find any nodejs module that supports these.
In the end, I only need to expose COM-OLE objects/interfaces to any applications running inside the PC so that they can access my application.
Thanks and BTW, I am using Electron.js.
Since win32ole only appears to operate as a client, you're stuck either:
Implementing your own COM server in C++ (nan helps with the node glue)
Writing a COM server in .NET and using edge for the node glue.

How can I mount easyrtc on webserver?

I'm trying to develop a video chat web-application with webrtc using easyrtc. I have developed it on my local machine. It runs well with node.js server on my localhost. But how can I mount it on my web-server? That means, when a user visit my website, he will able to video chat by this.
Very simple..put your project on sever, open firewall that allows connection throws in and out. Then integrate with your authentication system..
Done
If you have developed the application on node.js, you only have to follow the deploying procedure for an node.js app. In case that you have an app (php, ruby, python or others) that uses easyrtc as an signaling server, you can deploy your easyrtc and app to the same server or separately.
On the secon case you should use easyrtc.setSocketUrl("//mydomain.com:8080"); to avoid connection issues related to socket.io. For more info on this see:
https://easyrtc.com/docs/easyrtc_with_other_servers.php
Also remember that you application needs to work with https to work correctly in Chrome. See this:
https://developers.google.com/web/updates/2015/10/chrome-47-webrtc

Resources