vysper 地址已被使用
Posted
技术标签:
【中文标题】vysper 地址已被使用【英文标题】:vysper address already in use 【发布时间】:2014-09-09 10:22:00 【问题描述】:我想在 Java 项目中使用 XMPP 服务器“Apache Vysper”,所以我复制了这个示例代码:
public class Start
/**
*
* @param args
*/
public static void main(String[] args) throws AccountCreationException,
EntityFormatException, FileNotFoundException
// choose the storage you want to use
//StorageProviderRegistry providerRegistry = new JcrStorageProviderRegistry();
StorageProviderRegistry providerRegistry = new MemoryStorageProviderRegistry();
final AccountManagement accountManagement = (AccountManagement) providerRegistry
.retrieve(AccountManagement.class);
Entity user1 = EntityImpl.parse("user1@vysper.org");
if (!accountManagement.verifyAccountExists(user1))
accountManagement.addUser(user1, "password1");
Entity user2 = EntityImpl.parse("user2@vysper.org");
if (!accountManagement.verifyAccountExists(user2))
accountManagement.addUser(user2, "password1");
Entity user3 = EntityImpl.parse("user3@vysper.org");
if (!accountManagement.verifyAccountExists(user3))
accountManagement.addUser(user3, "password1");
XMPPServer server = new XMPPServer("vysper.org");
server.addEndpoint(new TCPEndpoint());
WebSocketEndpoint wsEndpoint = new WebSocketEndpoint()
// example of how you can combine Vysper with other resources
@Override
protected Server createJettyServer()
Server jetty = super.createJettyServer();
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setResourceBase("src/examples/client");
jetty.setHandler(resourceHandler);
HandlerCollection handlers = new HandlerCollection();
handlers.addHandler(resourceHandler);
jetty.setHandler(handlers);
return jetty;
;
wsEndpoint.setContextPath("/ws");
server.addEndpoint(wsEndpoint);
server.setStorageProviderRegistry(providerRegistry);
server.setTLSCertificateInfo(new File("src/cert/bogus_mina_tls.cert"),
"boguspw");
try
server.start();
System.out.println("vysper server is running...");
catch (Exception e)
e.printStackTrace();
server.addModule(new SoftwareVersionModule());
server.addModule(new EntityTimeModule());
server.addModule(new VcardTempModule());
server.addModule(new XmppPingModule());
server.addModule(new PrivateDataModule());
但是当我运行代码时,我总是得到一个“java.net.BindException”:
log4j:WARN No appenders could be found for logger (org.apache.vysper.xmpp.server.DefaultServerRuntimeContext).
log4j:WARN Please initialize the log4j system properly.
java.net.BindException: Die Adresse wird bereits verwendet
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:414)
at sun.nio.ch.Net.bind(Net.java:406)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:214)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
at org.apache.mina.transport.socket.nio.NiosocketAcceptor.open(NioSocketAcceptor.java:248)
at org.apache.mina.transport.socket.nio.NioSocketAcceptor.open(NioSocketAcceptor.java:48)
at org.apache.mina.core.polling.AbstractPollingIoAcceptor.registerHandles(AbstractPollingIoAcceptor.java:525)
at org.apache.mina.core.polling.AbstractPollingIoAcceptor.access$200(AbstractPollingIoAcceptor.java:66)
at org.apache.mina.core.polling.AbstractPollingIoAcceptor$Acceptor.run(AbstractPollingIoAcceptor.java:406)
at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
我用的是 linux。
我做错了什么? 谢谢!
【问题讨论】:
【参考方案1】:根据您的错误,我认为该端口已被阻止。默认情况下,vysper 使用 5222 端口。检查您的防火墙或其他应用是否阻止了此端口。
【讨论】:
以上是关于vysper 地址已被使用的主要内容,如果未能解决你的问题,请参考以下文章
该电子邮件地址已被另一个帐户使用(使用电子邮件/密码 Firebase 进行身份验证)
jboss 服务器已启动。但显示 java.net.bind 异常;地址已被使用