Home | Search | Login | RSS
We have 1073 members and counting!
Next Page

1

Previous Page

Thread: The basics of connecting one server to another for FMS

Created on: 01/09/11 04:55 AM

Replies: 16

Graeme





Joined: 10/18/07

Posts: 1591

The basics of connecting one server to another
01/09/11 4:55 AM

This thread is for questions for the tutorial "The basics of connecting one server to another for FMS".

http://www.fmsguru.com/showtutorial.cfm?tutorialID=45
* Last updated by: Graeme on 1/9/2011 @ 5:01 AM *

Link | Top | Bottom

iforsyth





Joined: 01/25/11

Posts: 7

Having a server act as a client
01/25/11 4:22 AM

This might sound a little stupid, but I know that calling a function on server 2 was covered in the tutorial, but as I understand it, server 1 is now a client of server 2. If that's true, I'd like to be able to call a function on server one from server 2 (i.e. the other way round from the tutorial) and was wondering how different it would be?

EDIT: Just to clarify, I mean having the first server run code the way you would if it was a client (nc.client.functionName = function()) because I'm stumped.
* Last updated by: iforsyth on 1/26/2011 @ 7:53 AM *

Link | Top | Bottom

Graeme





Joined: 10/18/07

Posts: 1591

RE: The basics of connecting one server to another for FMS
01/28/11 8:45 PM

Server 1 becomes a client of server 2, keep track of that client object and then call functions with the call() method. Declare those on server 1 in either the Client.prototype or client object as they connect up. Should be good to go.

Link | Top | Bottom

iforsyth





Joined: 01/25/11

Posts: 7

RE: The basics of connecting one server to another for FMS
02/04/11 2:02 AM

Thanks for the help Graeme, now I have another question.

We have one server that should connect to another server, and that works fine when I test locally, all the connections go through, all the code is run correctly. When the applications are placed on the server, however, the connection no longer goes through. The connection address is correct as it is possible to connect to the second server from other sources with the same address. The applications sit alongside each other on the server.

I was just wondering if you've got any ideas about what may be stopping the connection from going through?

Link | Top | Bottom

Graeme





Joined: 10/18/07

Posts: 1591

RE: The basics of connecting one server to another for FMS
02/05/11 3:12 PM

I suspect it's a case issue. Like you are trying to connect to "myApp" and you are specifying "myapp". Just a thought. It's amazing how such a trivial item can catch you up and it looks the same otherwise. Give that a try, let me know.

Link | Top | Bottom

iforsyth





Joined: 01/25/11

Posts: 7

RE: The basics of connecting one server to another for FMS
02/06/11 2:58 AM

Thanks for getting back to me Graeme. I've gone through the code, and the case and spelling of each time I call the NetConnection object - i've called it application.tNetConn - is always the same.

Link | Top | Bottom

Graeme





Joined: 10/18/07

Posts: 1591

RE: The basics of connecting one server to another for FMS
02/06/11 9:37 AM

Yes, but what about the application name itself? Not the object name.

Link | Top | Bottom

iforsyth





Joined: 01/25/11

Posts: 7

RE:
02/06/11 3:20 PM

Sorry for the misunderstanding there Graeme, that could possibly be the issue, I'll test it in the morning to be sure though, thanks so much. One other question though: If the server apps reside on the same physical server, that should be ok, right?

EDIT: Just so you can see what I'm trying to do I'll include the basic code for connecting

SERVER 1:

view plain print about
1
2//SERVER 1
3
4application.allowDebug = true;
5
6application.onAppStart = function()
7{
8    application.nc = new NetConnection();
9    application.nc.objectEncoding = 3;
10    application.nc.connect("rtmp://ourserveraddress:1935/server2/testme")
11    application.nc.onStatus = function(info){
12        trace("connected: " + info.code + " and here's why: " + info.description);
13    }
14    trace("trying to connect");
15}
16
17application.onConnect = function(clientObj)
18{
19    application.acceptConnection(clientObj);
20}
21
22application.onDisconnect = function(clientObj)
23{
24
25}

SERVER 2:

view plain print about
1
2//SERVER 2
3
4
5application.allowDebug = true;
6
7application.onAppStart = function()
8{
9    trace("app started");
10}
11
12application.onConnect = function(clientObj)
13{
14    application.acceptConnection(clientObj);
15    trace("connected");
16}
17
18application.onDisconnect = function(clientObj)
19{
20
21}

and I'm getting a NetConnection.Connect.Rejected message
* Last updated by: iforsyth on 2/8/2011 @ 3:38 AM *

Link | Top | Bottom

Graeme





Joined: 10/18/07

Posts: 1591

RE: The basics of connecting one server to another for FMS
02/09/11 3:20 AM

Yes, if the apps are on the same server it's fine. Just a connection from one app to another.

Link | Top | Bottom

iforsyth





Joined: 01/25/11

Posts: 7

RE: The basics of connecting one server to another for FMS
02/09/11 3:56 AM

Thanks Graeme, I hate to be a nuisance, but is there something in my code that is missing, or that I'm just not getting?

Link | Top | Bottom

Graeme





Joined: 10/18/07

Posts: 1591

RE: The basics of connecting one server to another for FMS
02/09/11 1:04 PM

I don't think FMS server side supports AMF3 encoding. Try taking out that line.

Link | Top | Bottom

iforsyth





Joined: 01/25/11

Posts: 7

RE: The basics of connecting one server to another for FMS
02/10/11 4:33 AM

Thanks Graeme, took out that line, but it still doesn't work unfortunately. Does the rest of the code seem ok?

Link | Top | Bottom

Graeme





Joined: 10/18/07

Posts: 1591

RE: The basics of connecting one server to another for FMS
02/10/11 9:33 AM

I don't see any issues other than to double check your folder name:

/server2/testme

for the application name. If that's not a problem then I'm a bit stumped. Can you connect to "server2" from a flash file?

Link | Top | Bottom

iforsyth





Joined: 01/25/11

Posts: 7

RE: The basics of connecting one server to another for FMS
02/22/11 3:48 AM

Yeah you could, that was the strange thing. I got it working though, and here's the working code:

view plain print about
1
2application.allowDebug = true;
3
4application.onAppStart = function()
5{
6    trace("app started");
7}
8
9application.onConnect = function(clientObj)
10{
11    application.acceptConnection(clientObj);
12}
13
14Client.prototype.connectNext = function()
15{
16    application.nc = new NetConnection();
17    application.nc.connect("rtmp://ourserveraddress/server2/test")
18    application.nc.onStatus = function(info){
19        trace("connected: " + info.code + " and here's why: " + info.description);
20    }
21    trace("trying to connect");
22}
23
24NetConnection.prototype.sConnect = function(message)
25{
26    trace(message);
27    application.broadcastMsg("serverConnected");
28}
29
30application.onDisconnect = function(clientObj)
31{
32
33}

I think it was something to do with the instance names themselves. It didn't want to hook them up if one of them was using the default instance. Thanks for all your help Graeme.

Link | Top | Bottom

Graeme





Joined: 10/18/07

Posts: 1591

RE: The basics of connecting one server to another for FMS
02/22/11 12:24 PM

Good to hear you got it working, thanks for posting back with your success.

Link | Top | Bottom

e1





Joined: 03/10/11

Posts: 12

RE: The basics of connecting one server to another for FMS
04/28/11 3:52 AM

I have managed to connect using this example. Thank you.

Is it possible to connect each new user same way?
I have tryed using this code in application.onConnect instead of application.onAppStart but I am getting nothing. Not even startup traces.

Anyone please ?

Link | Top | Bottom

kjeske





Joined: 04/04/09

Posts: 26

RE: The basics of connecting one server to another for FMS
03/26/12 5:05 PM

Okay so i understand the concept of talking between applications/servers.

But i dont see how this is useful for true load balancing or routing requests.
For example.. say i'm building a chat application.

I have multiple chat rooms that i want people from chat room 1 to be able to talk to chat room 2 if they need to.

So i have a master host chat app that runs and manages whos in what room etc.
Then i have each room connect to that master chat host.
When user 1 from room 1 tries to talk to user 2 in room 2 they ask the host what room that person is in and then the host returns the room.

they problem is that this happens asynchronous from the actual context of the code..

take a look at this code:

view plain print about
1
2// looping through users to send data too
3for(var i=0;i<to.length;i++){
4         var id = to[i];
5        trace('PUSHING DATA: '+p_type+" user: "+to);
6        // if the user is not in our room/server
7        if(application.users[id] == undefined){
8// here i have to fetc the server the user is on.. but now that call will happen in another function inorder to get the return..
9
10            application.masterHost.call('findUserServer',response,userID);
11// instead it should work like
12response = application.masterHost.call(etc...);
13// that way i can continue the function and route calls to the right user..
14            continue;
15        }     
16    }

If anyone has any suggestions for how to approach this this me know!

Link | Top | Bottom

Next Page

1

Previous Page

New Post

Please login to post a response.