Opened 12 years ago

Closed 11 years ago

#659 closed defect (fixed)

WebAPI "Cannot establish connection". on different machine than server

Reported by: zspitzer Owned by:
Priority: medium Milestone:
Component: Web API Version: 2.0.1
Severity: minor Keywords:
Cc: External ID:

Description

Hi all!

I'm trying to use the .NET Api to establish a connection to a Mapguide 2.0.1 Site without using a Web Viewer. My Application is a smart client and should run on a different Machine the MapGuide Server runs on.

So I tried the following (in a Winforms Button_Click):

MapGuideApi?.MgInitializeWebTier?("webconfig.ini"); Connect to the site. MgUserInformation? userInfo = new MgUserInformation?("Administrator", "admin"); MgSiteConnection? siteConnection = new MgSiteConnection?(); siteConnection.Open(userInfo); MgResourceService? resService = (MgResourceService?)siteConnection.CreateService?(MgServiceType?.ResourceService?);

This works so far, but when I try to use the Resource-Service like this: MgResourceIdentifier? resID = new MgResourceIdentifier?("Library://"); MgByteReader? resEnum = resService.EnumerateResources?(resID, -1, "");

the API throws get an "OSGeo.MapGuide.MgConnectionFailedException?" (Message: "Cannot establish connection").

The same code works on the MapGuide Server Machine.

Is it possible to use the API to connect to a Mapguide Server on a different machine? Or do I have to use the Web-API (XML) over HTTP? I can change all my firewall rules, no problem.

Any Ideas? Thanx, Nothi

Change History (10)

comment:1 Changed 12 years ago by zspitzer

this happens with java as well. GetSite?().GetCurrentSiteAddress?() reports the correct address, but my local instance keeps getting hit with requests.

comment:2 Changed 12 years ago by trevorwekel

Hi Zac,

The Web Extensions looks in webconfig.ini to determine the IP address of the site to connect to. Have you updated the webconfig.ini to point to the desired server?

comment:3 Changed 12 years ago by zspitzer

Yep, I was using a modified copy of webconfig.ini

I am wondering if this might be only an issue with the java and .net api

there have been numerous posts on the mailing list about this problem

In my testing everything works fine with the connection until you try an hit the resource service, specifically MgResourceIdentifier?

comment:4 Changed 12 years ago by trevorwekel

MapGuide uses three ports for communication between the Server and Web Extensions. Do the ports match in serverconfig.ini and webconfig.ini? Can you create a connection using telnet for all the port numbers? Also, is the MachineIp? and IpAddress? in serverconfig.ini set to the public IP address of the server? If you have installed the server as "local web extensions", these addresses will be set to 127.0.0.1 and external web extensions will not be able to connect to the services.

comment:5 Changed 12 years ago by zspitzer

the ipaddress is correct in the webconfig.ini, i can telnet to the all three ports, and if i change the ip address the script doesn't connect

I tried to change the ip address in the serverconfig.ini from 127.0.0.1 to the real ip as reported by ipconfig, mapguide dies on startup and throws this error

The site server (10.3.64.35) must have the same IP address as this local server (127.0.0.1).

StackTrace?:

  • MgServer?.open line 1068 file d:\buildforgeprojects\mapguide_open_source_v2.0\build_27.13\mgdev\server\src\core\Server.cpp
  • MgServerManager?.Initialize line 187 file d:\buildforgeprojects\mapguide_open_source_v2.0\build_27.13\mgdev\server\src\common\manager\ServerManager?.cpp Logic exception.

changing the webconfig.ini to match didn't make a difference either.

my hunch is that the server value for the site ip address is being passed back to the web api for the resource service and that's why it's hitting my local mapguide server...

renaming the webconfig.ini file to something else throws an error

I can see the session being created on the remote server access.log and then I see this appear in my local access.log after the mapguide server has been freshly restarted (no createsession in the local access.logs since the restart either)

<2008-08-21T06:21:18> Administrator GetResourceContent?.1.0.0:2(Library://MAPS/COMBINED WEB BASE MAP.MapDefinition?,) Failure

comment:6 Changed 12 years ago by trevorwekel

In serverconfig.ini, both MachineIp and IpAddress should be set to 10.3.64.35. In webconfig.ini, IpAddress should be set to 10.3.64.35.

comment:7 Changed 12 years ago by tomfukushima

I think it would be a good idea to update the webconfig.ini and serverconfig.ini so that the documentation describes in more detail what IP Addresses should be set in these files. There have been a few cases now where people are not sure or are incorrect as to what the values should be (i.e., server box or web tier box IP address). Do these values show up in the server admin as well? Trevor, could you do the updates to the doc?

comment:8 Changed 12 years ago by zspitzer

ahh, i missed the machine IP, it's a bit confusing!

So serverconfig.ini has two configuration variables in separate sections which must always be the same..

I guess this dates back to the old site & support server stuff right?

So regardless of the serverconfig.ini config, for simplicity shouldn't the web API just use the webconfig.ini value, as you can't use any other values anyway.

comment:9 Changed 12 years ago by trevorwekel

The web extensions only uses IpAddress?. The server uses both MachineIp? and IpAddress?. All three should match. And yes, this is related to the original site and support server implementation.

The web API does only use the IpAddress? but the server creates the session identifiers. This means the server needs to know the "publicly visible" ip address.

comment:10 Changed 11 years ago by jbirch

Resolution: fixed
Status: newclosed

Sounds like this is "fixed"? If not, please re-open, or maybe open a new ticket as this one gets a bit confusing :)

Note: See TracTickets for help on using tickets.