从apache camel访问gmail时遇到此错误
[org.apache.camel.component.mail.MailConsumer] (Camel (camel-1) thread #1 - imaps://imap.gmail.com:993) Consumer Consumer[imaps://imap.gmail.com:993?consumer.delay=120000&delete=false&password=*****&unseen=true&username=abcdef%40gmail.com] failed polling endpoint: Endpoint[imaps://imap.gmail.com:993?consumer.delay=120000&delete=false&password=******&unseen=true&username=abcdef%40gmail.com]. Will try again at next poll. Caused by: [javax.mail.MessagingException - Connection timed out: connect]: javax.mail.MessagingException: Connection timed out: connect;
nested exception is:
java.net.ConnectException: Connection timed out: connect
at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:670) [mail-1.4.5-redhat-1.jar:1.4.5-redhat-1]
at javax.mail.Service.connect(Service.java:295) [mail-1.4.5-redhat-1.jar:1.4.5-redhat-1]
at org.apache.camel.component.mail.MailConsumer.ensureIsConnected(MailConsumer.java:376) [camel-mail-2.10.0.redhat-60024.jar:2.10.0.redhat-60024]
at org.apache.camel.component.mail.MailConsumer.poll(MailConsumer.java:82) [camel-mail-2.10.0.redhat-60024.jar:2.10.0.redhat-60024]
at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:142) [camel-core-2.10.0.redhat-60024.jar:2.10.0.redhat-60024]
at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:92) [camel-core-2.10.0.redhat-60024.jar:2.10.0.redhat-60024]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [rt.jar:1.7.0_51]
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304) [rt.jar:1.7.0_51]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178) [rt.jar:1.7.0_51]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [rt.jar:1.7.0_51]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_51]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_51]
at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_51]
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.TwoStacksPlainSocketImpl.socketConnect(Native Method) [rt.jar:1.7.0_51]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339) [rt.jar:1.7.0_51]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200) [rt.jar:1.7.0_51]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182) [rt.jar:1.7.0_51]
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) [rt.jar:1.7.0_51]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) [rt.jar:1.7.0_51]
at java.net.Socket.connect(Socket.java:579) [rt.jar:1.7.0_51]
at java.net.Socket.connect(Socket.java:528) [rt.jar:1.7.0_51]
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:319) [mail-1.4.5-redhat-1.jar:1.4.5-redhat-1]
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:233) [mail-1.4.5-redhat-1.jar:1.4.5-redhat-1]
at com.sun.mail.iap.Protocol.<init>(Protocol.java:113) [mail-1.4.5-redhat-1.jar:1.4.5-redhat-1]
at com.sun.mail.imap.protocol.IMAPProtocol.<init>(IMAPProtocol.java:111) [mail-1.4.5-redhat-1.jar:1.4.5-redhat-1]
at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:637) [mail-1.4.5-redhat-1.jar:1.4.5-redhat-1]
... 12 more
答案 0 :(得分:2)
删除端口号
imaps://imap.gmail.com?consumer.delay=120000&delete=false&password=*&unseen=true&username=abcdef%40gmail.com
再试一次。 将来请发布您的代码以及错误信息。