unable to connect to H2 database using extensions

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

Jeetesh Bhoria
Posts: 2
Joined: 24 Mar 2010, 16:48
Location: India

unable to connect to H2 database using extensions

Postby Jeetesh Bhoria » 26 Mar 2010, 14:32

Hi,

I am developing a game on iphone sdk and trying to connect to H2 database using extensions. I am using SmartFoxTris example for help. On my client side config.sys file i am writing:

<SmartFoxTrisConfig>
<ip>10.42.62.168</ip>
<port>9339</port>
<blueBoxIpAddress>10.42.62.168</blueBoxIpAddress>
<blueBoxPort>8080</blueBoxPort>
<smartConnect>true</smartConnect>
<httpPort>8080</httpPort>
<httpPollSpeed>750</httpPollSpeed>
<zone>sftris</zone>
<zone name="h2dbzone" customLogin="true">
<AutoReloadExtensions>true</AutoReloadExtensions>

<Rooms>
<Room name="Lobby" maxUsers="10" isPrivate="false" isTemp="false" autoJoin="true" />
</Rooms>

<DatabaseManager active="true">
<Driver>org.h2.Driver</Driver>
<ConnectionString>jdbc:h2:tcp://10.42.62.168:9009/examples</ConnectionString>

<UserName>sa</UserName>
<Password></Password>

<TestSQL><![CDATA[SELECT COUNT(*) FROM retrocomputers]]></TestSQL>

<MaxActive>10</MaxActive>
<MaxIdle>10</MaxIdle>

<OnExhaustedPool>fail</OnExhaustedPool>
<BlockTime>5000</BlockTime>
</DatabaseManager>

<Extensions>
<extension name="h2db_ext" className="internalDbDemo.as" type="script" />
</Extensions>
</zone>
</SmartFoxTrisConfig>

After using [smartFox sendXtMessage:@"h2db_ext" cmd:@"getList" paramObj:dictionary type:str roomId:-1]; to send message to the server. I got error on the gdb:
2010-03-26 20:05:10.486 iPhoneSmartFoxiPhoneClient_TicTacToe[3920:20b] INFSmartFoxiPhoneClient:send action:asObj fromRoom:38 message:<![CDATA[<dataObj><var n='object' t='s'>Hyderabad</var></dataObj>]]>
2010-03-26 20:05:10.487 iPhoneSmartFoxiPhoneClient_TicTacToe[3920:20b] INFSmartFoxiPhoneClient:makeXmlHeader
2010-03-26 20:05:10.487 iPhoneSmartFoxiPhoneClient_TicTacToe[3920:20b] INFSmartFoxiPhoneClient:closeHeader
2010-03-26 20:05:10.487 iPhoneSmartFoxiPhoneClient_TicTacToe[3920:20b] INFSmartFoxiPhoneClient:writeToSocket data:<msg t='sys'><body action='asObj' r='38'><![CDATA[<dataObj><var n='object' t='s'>Hyderabad</var></dataObj>]]></body></msg> len:123
2010-03-26 20:05:10.488 iPhoneSmartFoxiPhoneClient_TicTacToe[3920:20b] WRITE - Written directly to outStream len:123
2010-03-26 20:05:16.924 iPhoneSmartFoxiPhoneClient_TicTacToe[3920:20b] INFSmartFoxiPhoneClient:sendXtMessage xtName:h2db_ext cmd:getList roomId:-1
2010-03-26 20:05:25.272 iPhoneSmartFoxiPhoneClient_TicTacToe[3920:20b] INFSmartFoxiPhoneClient:sendString strMessage:%xt%h2db_ext%getList%38%Hyderabad%
2010-03-26 20:05:25.273 iPhoneSmartFoxiPhoneClient_TicTacToe[3920:20b] INFSmartFoxiPhoneClient:writeToSocket data:%xt%h2db_ext%getList%38%Hyderabad% len:35
2010-03-26 20:05:25.273 iPhoneSmartFoxiPhoneClient_TicTacToe[3920:20b] WRITE - Creating a new buffer
(gdb) continue
2010-03-26 20:05:58.300 iPhoneSmartFoxiPhoneClient_TicTacToe[3920:20b] Event type: EventHasSpaceAvailable
2010-03-26 20:05:58.316 iPhoneSmartFoxiPhoneClient_TicTacToe[3920:20b] WRITE - Written directly to outStream len:35
2010-03-26 20:05:58.317 iPhoneSmartFoxiPhoneClient_TicTacToe[3920:20b] Event type: EventHasSpaceAvailable
2010-03-26 20:05:58.317 iPhoneSmartFoxiPhoneClient_TicTacToe[3920:20b] WRITE - No data to send
------------------------------------------------------------------------------
The code is not going to - (void)onExtensionResponse:(INFSmartFoxSFSEvent *)evt
{
NSLog(@"Got Event");
}
Jeetesh Bhoria
Software Developer
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 29 Mar 2010, 19:32

The H2 database runs on the localhost, it is not exposed outside.
This line is not correct:

Code: Select all

<ConnectionString>jdbc:h2:tcp://10.42.62.168:9009/examples</ConnectionString>

You should use tcp://127.0.0.1:9009 etc...

As for the other problem I will ask Cem from Infosfer (the API maintainer) to take a look.
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
cemuzunlar
Posts: 47
Joined: 26 Dec 2008, 00:45
Contact:

Re: unable to connect to H2 database using extensions

Postby cemuzunlar » 31 Mar 2010, 15:54

There seems to be no error messages on the console.

It seems that you are making a call like this in the client:

[yourSfsObject sendObject:yourDictionary roomId:38];

(and yourDictionary has a variable named "object" with a value of "Hyderabad")

then you are making another call in the client:

[yourSfsObject sendXtMessage:@"h2db_ext" cmd:@"getList" paramObj:dictionary type:str roomId:-1];

There is an extension response handler in your client code but there seems to be no messages coming from your server. Did you handle your "getList" message in your extension code and send a response to the client?
Cem Uzunlar
Infosfer Game and Visualization Technologies
http://www.infosfer.com
contact@infosfer.com

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 92 guests