Jump to content
  • 0

MariaDb No connection


wongerlt

Question

Hello,

maybe some one had this error?:

java.sql.SQLException: No connection available within the specified time (option 'connectTimeout': 30,000 ms)
	at org.mariadb.jdbc.pool.Pool.getPoolConnection(Pool.java:382)
	at org.mariadb.jdbc.MariaDbPoolDataSource.getConnection(MariaDbPoolDataSource.java:79)
	at net.sf.l2j.commons.pool.ConnectionPool.getConnection(ConnectionPool.java:47)
    .....
    ...
    ..
    ..
    .
    

what can cause this error? Can't figure out

it start appear only maybe after half a day. Only in game server, on login server everything fine.
acis 401

 

what i have tried:

  1. Update mariadb connector to 3.1.2 ver.
  2. Restart vps.
  3. reinstall mariadb
Link to comment
Share on other sites

14 answers to this question

Recommended Posts

  • 0
2 hours ago, Trance said:


It's unusual to have connection issues on localhost. When this happens, check your computer's memory and processor usage. If they're too high, it might cause timeouts. Also, look at your MySQL settings, especially max_allowed_packet and wait_timeout. If they're too low, increase them. Have you changed any settings before?
 

Poorly written queries can also cause connection issues. You can perform a Java Flight Recording: https://maxcheaters.com/topic/247610-jdk-mission-control-performance-analysis-tool/

I think i found where is problem.

 

// with this i get errors (No connection available within the specified time (option 'connectTimeout': 30,000 ms)

private void updateDatabase()
{
   try {
      Connection con = ConnectionPool.getConnection();
      PreparedStatement stm = con.prepareStatement("DELETE FROM dungeon");
      stm.executeUpdate();
   }catch (Exception e)
   {
      e.printStackTrace();
   }
}

// with this no errors

private void updateDatabase()
{
	try(Connection con = ConnectionPool.getConnection()) {
	 PreparedStatement stm = con.prepareStatement("DELETE FROM dungeon");
	 stm.executeUpdate();
	}catch (Exception e)
	{
	e.printStackTrace();
	}
}

 

who can explain why? 😄

Link to comment
Share on other sites

  • 0

check your mariadb logs in vps, it might give you the reason, also if it only starts to appear after half a day, you might exceed max connections of mariadb and it blocks any further connections, by default it's set to 150, and if you added some custom to 401 acis it might not be closing them properly.
in this case you can increase the amount based on your need.

you can check current max connections with 

SHOW VARIABLES LIKE "max_connections";


you can also run below which will shows current connections and max used connections since mariadb session started:
 

show status where variable_name = 'threads_connected' OR variable_name = 'max_used_connections';


hope this helps.

Link to comment
Share on other sites

  • 0
3 minutes ago, Friko said:

check your mariadb logs in vps, it might give you the reason, also if it only starts to appear after half a day, you might exceed max connections of mariadb and it blocks any further connections, by default it's set to 150, and if you added some custom to 401 acis it might not be closing them properly.
in this case you can increase the amount based on your need.

you can check current max connections with 

SHOW VARIABLES LIKE "max_connections";


you can also run below which will shows current connections and max used connections since mariadb session started:
 

show status where variable_name = 'threads_connected' OR variable_name = 'max_used_connections';


hope this helps.

No players in server.

max connections: 256.

active coneections: 3

max_used_connections: 70

 

so problem not there. and in mariadb logs no errors 

Link to comment
Share on other sites

  • 0

Ensure that the following information in your server properties is accurate: the database URL, login credentials, and password.  If you are using Linux, it's a good idea to verify if any firewall rules might be blocking the loopback interface (lo) for localhost, as this could be the cause of the issue.

Link to comment
Share on other sites

  • 0
54 minutes ago, wongerlt said:

No players in server.

max connections: 256.

active coneections: 3

max_used_connections: 70

 

so problem not there. and in mariadb logs no errors 


players don't need to be in server to drain max connections in some packs.

then check if db user itself has rate limits enabled, I would assume db is in local vps as your gameserver, so no limits are needed as long as you use it only for server itself.
database connections per hour, user connections per hour etc.
if you copied some guides how to create DB user they may have included rate limiters.

Link to comment
Share on other sites

  • 0
37 minutes ago, Friko said:


players don't need to be in server to drain max connections in some packs.

then check if db user itself has rate limits enabled, I would assume db is in local vps as your gameserver, so no limits are needed as long as you use it only for server itself.
database connections per hour, user connections per hour etc.
if you copied some guides how to create DB user they may have included rate limiters.

there no limits for user.

https://prnt.sc/eJB2oWTgdo8G

1 hour ago, Trance said:

Ensure that the following information in your server properties is accurate: the database URL, login credentials, and password.  If you are using Linux, it's a good idea to verify if any firewall rules might be blocking the loopback interface (lo) for localhost, as this could be the cause of the issue.

db url:
jdbc:mariadb://127.0.0.1:3306/SERVER_DB?user=hidden&password=hidden

everything fine with user/pass/db.

im using linux it have iptables and firewalld but everything fine here.

10 minutes ago, Trance said:

 

Temporarily stop them.

 

sudo systemctl stop firewalld
sudo systemctl stop iptables

 

hm, i will try, now i enabled all logs which i found , will see tomorrow

Link to comment
Share on other sites

  • 0
34 minutes ago, wongerlt said:

there no limits for user.

https://prnt.sc/eJB2oWTgdo8G

db url:
jdbc:mariadb://127.0.0.1:3306/SERVER_DB?user=hidden&password=hidden

everything fine with user/pass/db.

im using linux it have iptables and firewalld but everything fine here.

 

Temporarily stop them:

 

sudo systemctl stop firewalld
sudo systemctl stop iptables


Check if localhost can reach MySQL on port 3306:

 

mysql -u root -h localhost -p<your password> -e "SELECT 'Connected Successfully'"

Link to comment
Share on other sites

  • 0
8 minutes ago, Trance said:

 

Temporarily stop them:

 

sudo systemctl stop firewalld
sudo systemctl stop iptables


Check if localhost can reach MySQL on port 3306:

 

mysql -u root -h localhost -p<your password> -e "SELECT 'Connected Successfully'"

 

yes localhost and 127.0.01 connect successfully. Like i said error start throwing only after some hours.

Link to comment
Share on other sites

  • 0
5 minutes ago, wongerlt said:

yes localhost and 127.0.01 connect successfully. Like i said error start throwing only after some hours.

 

That is not normal. However, you can increase connection timeout to 60 seconds for testing purposes.
 

jdbc:mariadb://127.0.0.1:3306/SERVER_DB?connectTimeout=60000?user=hidden&password=hidden


All you can do is wait for the logging results.

Link to comment
Share on other sites

  • 0
4 hours ago, wongerlt said:

yes localhost and 127.0.01 connect successfully. Like i said error start throwing only after some hours.

so you db is up , ls is still online without any problem but your gs is having trouble connecting to db sometimes ?

Link to comment
Share on other sites

  • 0
6 hours ago, wongerlt said:

yes localhost and 127.0.01 connect successfully. Like i said error start throwing only after some hours.

Can u share your linux distro and if you have applied any settings on it?

Link to comment
Share on other sites

  • 0
9 hours ago, LoVe+ said:

so you db is up , ls is still online without any problem but your gs is having trouble connecting to db sometimes ?

yes.

13 hours ago, Trance said:

 

That is not normal. However, you can increase connection timeout to 60 seconds for testing purposes.
 

jdbc:mariadb://127.0.0.1:3306/SERVER_DB?connectTimeout=60000?user=hidden&password=hidden


All you can do is wait for the logging results.

i got one error:
[Warning] Aborted connection 3 to db: 'SERVER_DB' user: 'root' host: 'localhost' (Got timeout reading communication packets)

Link to comment
Share on other sites

  • 0
5 hours ago, wongerlt said:

yes.

i got one error:
[Warning] Aborted connection 3 to db: 'SERVER_DB' user: 'root' host: 'localhost' (Got timeout reading communication packets)


It's unusual to have connection issues on localhost. When this happens, check your OS' RAM and CPU usage. If they're too high, it might cause timeouts. Also, look at your MySQL settings, especially max_allowed_packet and wait_timeout. If they're too low, increase them. Have you changed any settings before?
 

Poorly written queries can also cause connection issues. You can perform a Java Flight Recording: https://maxcheaters.com/topic/247610-jdk-mission-control-performance-analysis-tool/

Edited by Trance
Link to comment
Share on other sites

  • 0
12 minutes ago, wongerlt said:

I think i found where is problem.

 

// with this i get errors (No connection available within the specified time (option 'connectTimeout': 30,000 ms)

private void updateDatabase()
{
   try {
      Connection con = ConnectionPool.getConnection();
      PreparedStatement stm = con.prepareStatement("DELETE FROM dungeon");
      stm.executeUpdate();
   }catch (Exception e)
   {
      e.printStackTrace();
   }
}

// with this no errors

private void updateDatabase()
{
	try(Connection con = ConnectionPool.getConnection()) {
	 PreparedStatement stm = con.prepareStatement("DELETE FROM dungeon");
	 stm.executeUpdate();
	}catch (Exception e)
	{
	e.printStackTrace();
	}
}

 

who can explain why? 😄

 

It is closing the connection automatically because the Connection object is being created within the try block.

Edited by Trance
  • Thanks 1
  • Haha 1
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


  • Posts

    • Totally understood. You are right. I am not denying the time and the effort that you guys have poured in learning and developing yourselves as able devs. If I am not a learner then I would have bought a ready solution like korean client worked-out (not sure if there is. I have never tried to look for) Frankly, I have never bought any packs or some stuffs but just been working on a pure pack from l2j by myself. Actually I am not asking you guys to do everything for me. I just looked for a clue to solve my problem. (I am a korean and there is no korean community for l2j developing) I searched this forum for related articles and found some but all the instructions were just from normal users, not devs. They just shared their thoughts or opinions not apt informations. Namely, I could not get any clue for my problem.   Anyways, I already gave up to mod client due to lack of informations and knowleges. Have a good day brother.
    • Hi, I have seen in l2gold.in that there is an item that when clicked spawns a mob/raid_boss ramdom, this is edited from the ai or you have to create a mod in extender?, I am using the Dandiarena datapack.   I have seen the skill to spawn a pet with an item (dragon flaute) and I have seen the s_skill to spawn the unicorns (elemental summoner), I tried to create a s_summon of a raid boss but it threw error, for this reason I decided to come here to ask, this can help many people.   --------------------------------------------------------------------------------------------------------------------------------   SPAWN CAT: skill_begin    skill_name=[s_summon_blackcat1]    /* [쀜뀼 삣 끔 삣] */    skill_id=1111    level=1    operate_type=A1    magic_level=20    effect={{i_summon;[cat_the_cat_a];70;[crystal_d];0}}    operate_cond={{can_summon}}    is_magic=1    mp_consume1=8    mp_consume2=31    item_consume={[crystal_d];3}    cast_range=-1    effective_range=-1    skill_hit_time=15    skill_cool_time=0    skill_hit_cancel_time=0.5    reuse_delay=21600    attribute=attr_none    effect_point=0    target_type=self    affect_scope=single    affect_limit={0;0}    next_action=none    ride_state={@ride_none;@ride_wind;@ride_star;@ride_twilight}    skill_end   SPAWN ITEM (DB +10): skill_begin    skill_name=[s_en_draconic_bow_focus_10_box]    /* [Box with Draconic Bow Focus + 10] */    skill_id=10043    level=1    operate_type=A1    magic_level=1    effect={{i_add_enchanted_item;7577;10}}    is_magic=0    mp_consume2=0    item_consume={[en_draconic_bow_focus_10_box];1}    cast_range=-1    effective_range=-1    skill_hit_time=0.2    skill_cool_time=0    skill_hit_cancel_time=0    reuse_delay=0    attribute=attr_none    effect_point=0    target_type=self    affect_scope=single    affect_limit={0;0}    next_action=none    ride_state={@ride_none;@ride_wind;@ride_star;@ride_twilight}    skill_end   DRAGON FLAUTE: skill_begin    skill_name=[s_wolf_collar]    /* [Modified 15 May 2009 18:44] */    skill_id=2046    level=1    operate_type=A1    magic_level=1    effect={{i_summon_pet}}    operate_cond={{can_summon_pet};{op_not_territory;{{51341;218103;-3252;-2932};{53341;218103;-3252;-2932};{53341;220103;-3252;-2932};{51341;220103;-3252;-2932}}}}    is_magic=0    mp_consume2=0    cast_range=-1    effective_range=-1    skill_hit_time=5    skill_cool_time=0    skill_hit_cancel_time=0.5    reuse_delay=0    attribute=attr_none    effect_point=0    target_type=self    affect_scope=single    affect_limit={0;0}    next_action=none    ride_state={@ride_none}    skill_end     ITEM WITH RAMDOM DROP (GIFT/BOX): skill_begin    skill_name=[s_ingredient_box_1]    /* [샜쁽쁘 상삐] */    skill_id=2175    level=1    operate_type=A1    magic_level=1    effect={{i_restoration_random;{{{{[blood_root];2}};20};{{{[sulfur];2}};20};{{{[infernium_ore];1}};35};{{{[demons_blood];2}};25}}}}    is_magic=2    mp_consume2=0    item_consume={[ingredient_box];1}    cast_range=-1    effective_range=-1    skill_hit_time=0    skill_cool_time=0    skill_hit_cancel_time=0    reuse_delay=0    attribute=attr_none    effect_point=0    target_type=self    affect_scope=single    affect_limit={0;0}    next_action=none    ride_state={@ride_none;@ride_wind;@ride_star;@ride_twilight}    skill_end   --------------------------------------------------------------------------------------------------------------------------------   SPAWN RAID BOSS/MOB W/ ITEM: ??? HELP!     --------------------------------------------------------------------------------------------------------------------------------   I am learning how to create an OFF server, but I have many doubts, I would like you to guide me, I would appreciate it very much!    
    • Hello, is possible any effect spawn raid boss/mobs?
    • wts 100kk adena set mj light unsealed set nightmare sealed set tallum heavy unsealed set jewels tts unsealed! soul bow ITEMS C GRADE  l2reborn origins x1
    • WTB AQ Reborn Origins x1  Only middleman.  discord: Mr.Saran#1369
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock