I'm new to Network programming in Unity3D and basically I would like to make a connection between two android devices, through WiFi using the Client Server Model. And I have some questions.. such as
How it is possible to make a server with a specific IP Address?
How can I make a client, who will connect to that server?
How can I transfer messages between client(s) and server?
Any help would be appreciated..
.......
I have write this simple code...
function OnGUI()
{
if(GUILayout.Button(" Initlized server"))
{
Network.InitializeServer(32,25001,false);
Debug.Log("Server has been Initlized");
}
if(GUILayout.Button("connect to server"))
{
Network.Connect("127.0.0.1",25001);
}
}
function OnConnectedToServer() {
Debug.Log("Connected to server");
// Send local player name to server ...
}
I have write this simple code but OnConnectedToServer doesnot give me any responce...
How it is possible to make a server with a specific IP Address?
For the IP address part, you will need a static IP. If you are behind a router, that means you will have to first ensure your ISP gives you a static IP. If they don't, you should try a service such as FreeDNS, which will route your dynamic IP to a web address. You will then need to port forward the specific ports to the server, which should have a static local IP for easy port forwarding.
As for the code itself, I would highly recommend you take a look at THIS website. It has great video tutorials on making a client-server game using Unity's built in networking.
http://www.gamertogamedeveloper.com/
As for your code, you don't state how you run that code. You SHOULD NOT have the client and server being run in the SAME instance. What you need to do to test this is run the Server inside the Unity3d debugger then build the client and run it as a standalone app.
Raknet seems interesting,
have a look here:
RakNet
unity-Raknet
Related
I have a server and an android app. My server want to request a destination but with the IP of the android device that my app is running on. So I need to proxy the requests (relay them) in my app so the destination could see the client's IP but the server. You can see my explanation in the picture:
How can I do this in my app?
Yes this could be done but not just with relays; you also need to port forwarding mechanism in between. Here is how I would try to do this:
Local portforward the requests of the server onto a dedicated port on your android device and then from their call the Destination server via your relay mechanism which could be fulfilled very succicntly by LittleProxy like solution.
I have created a basic web service and I need to access it from android but somehow the web service is only accessible on my local machine, with a local URL like http://localhost:4012/MainWebService.asmx but outside my machine when I try something like 187.120.36.4:4012/MainWebService.asmx the 187.120.36.4 being the IP of my machine hosting the asp.net web service it doesn't go through, all my googling efforts have not paid off so far. So any help will be highly appreciated guys and thanks in advance.
First you need IIS Server. This is how to enable it on W10.
Next you need to configure you ASP project to run on the IIS server.
Now you should be able to access your webservice on 187.120.36.4:4012/MainWebService.asmx.
BTW. That looks like your external IP. Are you sure it is correct? I would suspect something like 192.168.x.xxx
If your machine is connected to a router then you need enable port forwarding on your router to your local machine and then run your web service in your local machine.
After you have it set up your connect url will be http://<your public ip address>:port number where public ip address is your router's external ip address.
So this is a two part question:
Part a: I'm trying to implement a secure connection to the KMS. From the documentation, I've understood that KMS Configuration file would need to be updated with the SSL certificate and then the HTTPS connection from the client can be made. Please let me know if there are any other steps that are involved in achieving SSL security.
Part b: From a better understanding now and from comments from a previous question I posted, Kurento Utils does not connect to KMS directly (this was an fyi and a clarification I received and I wanted documented here just in case). Now I'm trying to use Kurento Client to connect to KMS and I'm trying to understand the role of ICE/TURN/STUN servers acting as negotiators in the middle. If I were to specify my own server URL, I'm assuming that I would not need to include "freeice" and "normalice" and instead specify my own server's URL. In the code snippet below taken from the tutorial on github, I'm assuming that I would need to replace the argument for ice_servers to point to the url where my server is running? Or since this is the client, do I really need an ICE server because as said from the first statement, the utils don't connect to the KMS but the client can, right? So if I were to specify the Kurento URL for "ws_uri" parameter, then I won't need to even use ICE servers...right? I don't really understand the concept of ICE/TURN servers very well in terms of how they integrate with Kurento and hence, I would like to understand in English as to what changes would I need to make in order to get this to work. I will bang my head to write the code myself! Thanks much in advance!
`
var args = getopts(location.search,
{
default:
{
ws_uri: 'ws://' + location.hostname + ':8888/kurento',
file_uri: 'file:///tmp/recorder_demo.webm', //file to be stored in media server
ice_servers: undefined
}
});`
Answer A
Only this and nothing more... at least for KMS. On the client side, you'll need to specify the WSS port and so on.
Answer B
Your client might need a STUN/TURN server, and that's independent of where KMS is located. STUN and TURN are used in the candidate harvest process, to discover the network topology of your peer. You have two peers: KMS and your Android app, and both need to have, in their SDPs and during the negotiation, a candidate that is reachable by them (app will connect with KMS and viceversa) If both peers are on the same network, you can go without using STUN/TURN. The moment you have a NAT in between, you need at least STUN for that peer to be able to harvest candidates that have the public IP on the other side of the NAT, which is not known by the peer unless STUN is used.
TURN is used as a relay server, and it is needed in a small set of cases. If you are almost certain you are going to use TURN, you need to have that in a machine different than KMS (it makes close to no sense to have both the relay server and the media server installed together)
So the answer is yes, you are most likely going to need STUN/TURN in your clients.
I would like to know what field within the http packet which was sent by client browser to WEB server can i look to detect whether the request was made from mobile device or from a PC.
My web server is open source which uses C programming language and runs a TCP socket and listens on HTTP port.
Can anyone please let me know.
You need to see for HTTP header called "User-Agent". The value of this will help you determine where the request was made from.
For further details you can check this answer: Auto detect mobile browser (via user-agent?)
I wrote a little WS on asp.net, I can open it printing something like
http://46.146.170.225/RouteGen/Service.asmx
in address bar. It's all right, WS works.
But if I print the same address in a browser on the other computer, the page isn't available. How to get access to my web server from other PC? (I need from Android device, but I think it's no difference)
If you started the Web-Service from within Visual Studio then without changing the starup-settings of your project - it's not possible, because VS only starts a local debug web-server that doesn't allow calls from other hosts than localhost.
To allow external IPs to access your web-server, you have to set up the IIS and run your web-service inside it. A firewall could block incoming requests to the IIS but I ran such a service last winter and didn't have to change firewall-settings.
Verify that the website, in IIS, is bound to a public-facing IP address. Right click on your website in IIS, and go to the bindings setting. Then, check the host field. It should have an IP address or domain name that is available publicly.
Verify that your firewall has Port 80 open for incoming traffic