Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection pool shut down #6

Open
wanghui0574xs opened this issue Sep 11, 2018 · 2 comments
Open

Connection pool shut down #6

wanghui0574xs opened this issue Sep 11, 2018 · 2 comments

Comments

@wanghui0574xs
Copy link

java.lang.IllegalStateException: Connection pool shut down
at org.apache.http.util.Asserts.check(Asserts.java:34)
at org.apache.http.pool.AbstractConnPool.lease(AbstractConnPool.java:191)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.requestConnection(PoolingHttpClientConnectionManager.java:267)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:176)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108)
at com.swjtu.trans.impl.GoogleTranslator.query(GoogleTranslator.java:73)
at com.swjtu.trans.AbstractTranslator.run(AbstractTranslator.java:42)
at com.swjtu.querier.Querier.execute(Querier.java:25)

@blazezhazha
Copy link

blazezhazha commented Nov 9, 2018

Update on 12th, Nov, 2018
It seems that each translator instance can only be used for one translation. This Exception can be avoided if you detach the translator immediately after you use it and renew a different translator for the next translation. A simple demo may like the following:

BaiduTranslator baiduTranslator = new BaiduTranslator();
querierTrans.attach(baiduTranslator);
querierTrans.setParams(LANG.ZH, LANG.EN, source);  
List<String> targets = querierTrans.execute();
querierTrans.detach(baiduTranslator);

for(String target: targets){
    baiduTranslator = new BaiduTranslator();
    querierTrans.attach(baiduTranslator);
    querierTrans.setParams(LANG.EN, LANG.ZH, target);
    List<String> source_ = querierTrans.execute();
    querierTrans.detach(baiduTranslator);
} 

But this solution is rather complicated and time-consuming..

This project is fairly helpful!
But when I tried to translate from A to B and immediately from B to A like this:

querierTrans.setParams(LANG.ZH, LANG.EN, source);  
List<String> targets = querierTrans.execute();
for(String target: targets){
    querierTrans.setParams(LANG.EN, LANG.ZH, target);
    List<String> source_ = querierTrans.execute();
} 

I met the very same issue as shown above.
This problem has nothing to do with which translator I chose. Since I knew few about the HttpClient sort of thing, it's hard for me to understand why this happened.
Thank you.

@qiao18234034740
Copy link

遇到这种情况怎么办,被谷歌限制了

rg.apache.http.conn.HttpHostConnectException: Connect to www.google.com:443 [www.google.com/127.0.0.1, www.google.com/2404:6800:4012:0:0:0:0:2004] failed: Connection timed out: connect
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:151)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:107)
at com.swjtu.trans.impl.GoogleTranslator.query(GoogleTranslator.java:74)
at com.swjtu.trans.AbstractTranslator.run(AbstractTranslator.java:42)
at com.swjtu.querier.Querier.execute(Querier.java:25)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants