emysql add_poop() 超时出错
(金庆的专栏)
sample/a_hello.erl 连接本机更改为连接局域网内的MySql服务器:
emysql:add_pool(hello_pool, [{size,1},
{host, "192.168.1.2"},
...
编译运行时会出现超时退出:
D:\...\deps\emysql\samples>erl -pa ../ebin -s a_hello run -s init stop -noshell
add_pool...{"init terminating in do_boot",{{nocatch,{failed_to_recv_packet_header,timeout}},[{init,start_it,1,[{file,"init.erl"},{line,1062}]},{init,start_em,1,[{file,"init.erl"},{line,1034}]}]}}
Crash dump is being written to: erl_crash.dump...done
init terminating in do_boot ()
设置 default_timeout 参数为 10s 就可以成功:
D:\...\deps\emysql\samples>erl -pa ../ebin -s a_hello run -s init
stop -noshell -emysql default_timeout 10000
查看代码,缺省的 default_timeout 为8s。
当MySql没有skip-name-resolve时,连接MySql需要近10秒才能连上,
所以很容易出现超时错误。
已提交问题:
https://github.com/Eonblast/Emysql/issues/174