• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 14:03
CEST 20:03
KST 03:03
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
[ASL20] Ro24 Preview Pt2: Take-Off7[ASL20] Ro24 Preview Pt1: Runway132v2 & SC: Evo Complete: Weekend Double Feature4Team Liquid Map Contest #21 - Presented by Monster Energy9uThermal's 2v2 Tour: $15,000 Main Event18
Community News
Weekly Cups (Aug 18-24): herO dethrones MaxPax6Maestros of The Game—$20k event w/ live finals in Paris31Weekly Cups (Aug 11-17): MaxPax triples again!13Weekly Cups (Aug 4-10): MaxPax wins a triple6SC2's Safe House 2 - October 18 & 195
StarCraft 2
General
Aligulac - Europe takes the podium A Eulogy for the Six Pool Geoff 'iNcontroL' Robinson has passed away Weekly Cups (Aug 18-24): herO dethrones MaxPax 2v2 & SC: Evo Complete: Weekend Double Feature
Tourneys
Sparkling Tuna Cup - Weekly Open Tournament Maestros of The Game—$20k event w/ live finals in Paris Esports World Cup 2025 WardiTV Mondays RSL: Revival, a new crowdfunded tournament series
Strategy
Custom Maps
External Content
Mutation # 488 What Goes Around Mutation # 487 Think Fast Mutation # 486 Watch the Skies Mutation # 485 Death from Below
Brood War
General
ASL20 - worst advertising ever... BGH Auto Balance -> http://bghmmr.eu/ ASL Season 20 Ro24 Groups Flash On His 2010 "God" Form, Mind Games, vs JD No Rain in ASL20?
Tourneys
[ASL20] Ro24 Group F [ASL20] Ro24 Group D [Megathread] Daily Proleagues [IPSL] CSLAN Review and CSLPRO Reimagined!
Strategy
Simple Questions, Simple Answers Fighting Spirit mining rates [G] Mineral Boosting Muta micro map competition
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread General RTS Discussion Thread Dawn of War IV Path of Exile
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine The year 2050 European Politico-economics QA Mega-thread
Fan Clubs
INnoVation Fan Club SKT1 Classic Fan Club!
Media & Entertainment
Anime Discussion Thread Movie Discussion! [Manga] One Piece [\m/] Heavy Metal Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion TeamLiquid Health and Fitness Initiative For 2023
World Cup 2022
Tech Support
High temperatures on bridge(s) Gtx660 graphics card replacement Installation of Windows 10 suck at "just a moment"
TL Community
The Automated Ban List TeamLiquid Team Shirt On Sale
Blogs
RTS Design in Hypercoven
a11
Evil Gacha Games and the…
ffswowsucks
Breaking the Meta: Non-Stand…
TrAiDoS
INDEPENDIENTE LA CTM
XenOsky
[Girl blog} My fema…
artosisisthebest
Sharpening the Filtration…
frozenclaw
ASL S20 English Commentary…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1194 users

Java RMI timeouts

Blogs > Freezard
Post a Reply
Freezard
Profile Blog Joined April 2007
Sweden1011 Posts
February 13 2011 16:23 GMT
#1
I'm doing a server/client program in Java using RMI. When server crashes it's not a problem, clients get a RemoteException and disconnects.

However I have problems when clients crashes. My server uses a Timer to ping all client objects every now and then, when it gets no connection to a client it will catch a RemoteException.

Then, it's supposed to remove the client object from the server (just by removing it from a list), but it's impossible because when I try to do anything with the proxy client object it will throw another RemoteException. How can I solve this problem?

*
2Pacalypse-
Profile Joined October 2006
Croatia9509 Posts
February 13 2011 16:25 GMT
#2
By posting in a more appropriate place, ie. http://stackoverflow.com/
Moderator"We're a community of geniuses because we've found how to extract 95% of the feeling of doing something amazing without actually doing anything." - Chill
Freezard
Profile Blog Joined April 2007
Sweden1011 Posts
February 13 2011 16:32 GMT
#3
I will try :-)
Cambium
Profile Blog Joined June 2004
United States16368 Posts
Last Edited: 2011-02-13 17:05:32
February 13 2011 16:59 GMT
#4
You need to be more specific and post some code. There could literally be 1000 things wrong with your code.

If you are just removing the client proxy objects from a list, I don't understand why you would need to invoke any actions upon the object itself...?

edit:

Let me rephrase it better: if you are simply removing an object from the list, you aren't actually doing anything with the object itself. You are merely removing its reference from the container.

edit2:

Also, I don't understand your design: you have your host ping your clients? A better approach would be to have your clients send a pulse to your server, and you can determine which client is down from that.
When you want something, all the universe conspires in helping you to achieve it.
Freezard
Profile Blog Joined April 2007
Sweden1011 Posts
February 13 2011 17:09 GMT
#5
I have never done remote programming. Isn't it common that servers ping their clients? Anyway I posted it here and I got some answers, will check it out.

http://stackoverflow.com/questions/4985343/java-rmi-timeouts-crashes
Cambium
Profile Blog Joined June 2004
United States16368 Posts
February 13 2011 17:13 GMT
#6
They are correct.

You call "getUser()" on a broken client, it will obviously throw exceptions.

A lot of valuable information in that thread if you are patient enough to sift through it.

re: client pinging

It's inefficient as the number of clients can grow without bound, and your server is doing all the work. If you have your clients ping your server, you distribute the workload onto the clients.
When you want something, all the universe conspires in helping you to achieve it.
Freezard
Profile Blog Joined April 2007
Sweden1011 Posts
February 13 2011 17:49 GMT
#7
Was a stupid mistake. I'm thinking about your method of pinging server instead. But I don't know how you could do that more efficient...
Trap
Profile Blog Joined May 2009
United States395 Posts
February 13 2011 18:43 GMT
#8
Your question makes no sense. By itself, the RMI server (registry) has no way of calling a method on a client; the server simply exposes a set of methods that a RMI client can call.

If your question is what happens if a client makes a RMI call on your RMI server and while the RMI server is processing the request, the server becomes unresponsive: you can set the socket timeout on the client and / or server to cleanly handle such a situation without resorting to polling (check out rmi socket factory or write a custom one).
coffeetoss | "Team Liquid Fantasy Proleague: Tales of Miserable Failure and Deep Regret" -Kanil
Macavenger
Profile Blog Joined January 2008
United States1132 Posts
February 13 2011 19:04 GMT
#9
On February 14 2011 02:49 Freezard wrote:
Was a stupid mistake. I'm thinking about your method of pinging server instead. But I don't know how you could do that more efficient...

You have (for example) each client ping the server once every minute. Every two minutes, the server goes through its list of clients and dumps any that it hasn't heard from since its last sweep. This is a lot more efficient for your server, as all it has to do is listen (which it does anyway) and go through a list checking a flag once every couple minutes. If you put your server in charge of the pinging, it has to periodically go through all the clients, ping each one, wait for responses, tag all of them, decide what an appropriate timeout is, etc. The total amount of work may be similar, but you'd rather have that work distributed to the clients which only have to maintain one connection each, rather than the server maintaining many connections.
Freezard
Profile Blog Joined April 2007
Sweden1011 Posts
February 13 2011 20:04 GMT
#10
On February 14 2011 04:04 Macavenger wrote:
Show nested quote +
On February 14 2011 02:49 Freezard wrote:
Was a stupid mistake. I'm thinking about your method of pinging server instead. But I don't know how you could do that more efficient...

You have (for example) each client ping the server once every minute. Every two minutes, the server goes through its list of clients and dumps any that it hasn't heard from since its last sweep. This is a lot more efficient for your server, as all it has to do is listen (which it does anyway) and go through a list checking a flag once every couple minutes. If you put your server in charge of the pinging, it has to periodically go through all the clients, ping each one, wait for responses, tag all of them, decide what an appropriate timeout is, etc. The total amount of work may be similar, but you'd rather have that work distributed to the clients which only have to maintain one connection each, rather than the server maintaining many connections.

OK. So in my case I would add a list of users. Every client pings the server with its user as argument. Server adds the user to the list plus any new clients who connect. After two minutes server checks for every user in the Map<User, Client> if the user also exists in the list. If not - remove that user. End by clearing the list.

Is this what you mean? I guess it's more efficient like you say.
Macavenger
Profile Blog Joined January 2008
United States1132 Posts
February 13 2011 20:27 GMT
#11
On February 14 2011 05:04 Freezard wrote:
Show nested quote +
On February 14 2011 04:04 Macavenger wrote:
On February 14 2011 02:49 Freezard wrote:
Was a stupid mistake. I'm thinking about your method of pinging server instead. But I don't know how you could do that more efficient...

You have (for example) each client ping the server once every minute. Every two minutes, the server goes through its list of clients and dumps any that it hasn't heard from since its last sweep. This is a lot more efficient for your server, as all it has to do is listen (which it does anyway) and go through a list checking a flag once every couple minutes. If you put your server in charge of the pinging, it has to periodically go through all the clients, ping each one, wait for responses, tag all of them, decide what an appropriate timeout is, etc. The total amount of work may be similar, but you'd rather have that work distributed to the clients which only have to maintain one connection each, rather than the server maintaining many connections.

OK. So in my case I would add a list of users. Every client pings the server with its user as argument. Server adds the user to the list plus any new clients who connect. After two minutes server checks for every user in the Map<User, Client> if the user also exists in the list. If not - remove that user. End by clearing the list.

Is this what you mean? I guess it's more efficient like you say.

Well, I'm not familiar with exactly what data structures you're using, or network coding in Java (I've only done it in C++), but that sounds essentially correct. I'm used to doing it as something like a list of IP/port pairs (clients) that the server has active connections to, and storing a boolean flag for each of them that indicates whether it has heard from them recently, and just clearing that flag, or logging out the client if the flag isn't set.
ramesh
Profile Joined November 2011
United States1 Post
November 13 2011 05:33 GMT
#12
Thank you. I am glad that i found this blog online. I was very impressed with the blog posting here about the topic.

We have an application in prod environment in our organization such as a server/client program in Java using RMI. Both server and client/s uses a Timer to ping each other at regular interval. If either one does not receive a reply when ping each other then after reaching a limit (> ping interval + tolerance), they end up disconnecting each other. In that process, the RMI server knocks out all other clients at certain times. Things seems to working file until a year back but after that the user base moved to a new building. Since then, we have noticed few network issues in the infrastructure and this particular application got effected very badly such that the application outage has been recurring once/twice per week. I have inherited this application code and maintenance from a vendor after i joined the organization. Recently we migrated the database part of the application to Oracle RAC and that effected some of the queries to take longer time than they were before. Ironically, all these issues are being surfaced only in prod environment but not in Test/Dev environment. It's been extremely challenging to resolve the issues. I would truly appreciate if someone provide me some guidance to resolve this issue.

Since past 2 days, 3 of the use case scenarios seems to be taking longer time to finish in the database and by that time, Socket Timeout (set to 15 sec) is being reach in each of the scenario. To our knowledge, we couldn't find any issue with the database sqls but we started looking into those to find root cause. In the meantime, i thought of increasing RMI Server Socket Timeout to 5min as interim solution.

Does this change have any side effects in this client/server model?

Please advise.

Thanks
Ram
MisterD
Profile Blog Joined June 2010
Germany1338 Posts
Last Edited: 2011-11-13 11:29:48
November 13 2011 11:28 GMT
#13
timeouts are usually used for error cases, so increasing the timeouts *should* not change anything for the normal program flow. however, as every engineer knows, changing anything can break everything. ;P

of course a "nicer" solution would be to use multithreading, as to still be able to reply to pings while the database is working. that is however considerably more work, which might not be justified depending on what your further plans with said application are.

/edit: oh and also the same goes for you, better post on stackoverflow.com for instance. this is not really a programmer help forum here, although quite a few programmers frequent it.
Gold isn't everything in life... you need wood, too!
Please log in or register to reply.
Live Events Refresh
Next event in 5h 57m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
mouzHeroMarine 425
ProTech101
UpATreeSC 100
goblin 42
BRAT_OK 33
MindelVK 12
StarCraft: Brood War
Britney 27407
Calm 3884
Horang2 1013
EffOrt 764
Bisu 707
Larva 321
ggaemo 255
Shuttle 150
Mong 132
Soulkey 95
[ Show more ]
Hyuk 85
JYJ56
Dewaltoss 51
Sharp 36
soO 30
Aegong 27
Killer 26
Yoon 23
ajuk12(nOOB) 21
HiyA 20
scan(afreeca) 19
Rock 16
Sacsri 15
NaDa 11
Beast 3
Dota 2
Gorgc7051
XcaliburYe379
Fuzer 277
LuMiX0
Counter-Strike
fl0m4922
olofmeister3275
flusha203
Other Games
FrodaN1097
Lowko396
RotterdaM374
KnowMe211
Grubby147
Trikslyr65
markeloff55
QueenE54
trigger2
fpsfer 0
Organizations
StarCraft 2
angryscii 18
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 15 non-featured ]
StarCraft 2
• Reevou 3
• intothetv
• AfreecaTV YouTube
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• WagamamaTV698
League of Legends
• TFBlade1081
Counter-Strike
• imaqtpie537
• Shiphtur123
Upcoming Events
Replay Cast
5h 57m
The PondCast
15h 57m
WardiTV Summer Champion…
16h 57m
herO vs MaxPax
Clem vs Classic
Replay Cast
1d 5h
LiuLi Cup
1d 16h
MaxPax vs TriGGeR
ByuN vs herO
Cure vs Rogue
Classic vs HeRoMaRinE
Cosmonarchy
1d 21h
OyAji vs Sziky
Sziky vs WolFix
WolFix vs OyAji
BSL Team Wars
2 days
Team Hawk vs Team Dewalt
BSL Team Wars
2 days
Team Hawk vs Team Bonyth
SC Evo League
2 days
TaeJa vs Cure
Rogue vs threepoint
ByuN vs Creator
MaNa vs Classic
Maestros of the Game
2 days
ShoWTimE vs Cham
GuMiho vs Ryung
Zoun vs Spirit
Rogue vs MaNa
[ Show More ]
[BSL 2025] Weekly
2 days
SC Evo League
3 days
Maestros of the Game
3 days
SHIN vs Creator
Astrea vs Lambo
Bunny vs SKillous
HeRoMaRinE vs TriGGeR
BSL Team Wars
4 days
Team Bonyth vs Team Sziky
BSL Team Wars
4 days
Team Dewalt vs Team Sziky
Monday Night Weeklies
4 days
Replay Cast
5 days
Sparkling Tuna Cup
5 days
Liquipedia Results

Completed

CSLAN 3
uThermal 2v2 Main Event
HCC Europe

Ongoing

Copa Latinoamericana 4
BSL 20 Team Wars
KCM Race Survival 2025 Season 3
BSL 21 Qualifiers
ASL Season 20
CSL Season 18: Qualifier 1
Acropolis #4 - TS1
CSL Season 18: Qualifier 2
SEL Season 2 Championship
WardiTV Summer 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
BLAST.tv Austin Major 2025

Upcoming

CSL 2025 AUTUMN (S18)
LASL Season 20
BSL Season 21
BSL 21 Team A
Chzzk MurlocKing SC1 vs SC2 Cup #2
RSL Revival: Season 2
Maestros of the Game
EC S1
Sisters' Call Cup
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
MESA Nomadic Masters Fall
CS Asia Championships 2025
Roobet Cup 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.