Project

General

Profile

User affiliations reading error when client getUserSubscriptions

Livia Yu
Added 2 months ago

Hi,

I have use tigase 7.1.4 and pubsub Component. And when using it, I have met the exception with two different domains during client getUserSubscriptions.
After restart the service, the problem resolved.
Please help to check if anything wrong config leads to the problem. Thanks.

java.lang.RuntimeException: tigase.pubsub.repository.RepositoryException: User affiliations reading error
    at tigase.pubsub.modules.RetrieveSubscriptionsModule.process(RetrieveSubscriptionsModule.java:161)
    at tigase.component2.modules.ModulesManager.process(ModulesManager.java:114)
    at tigase.component2.AbstractComponent.processStanzaPacket(AbstractComponent.java:248)
    at tigase.component2.AbstractComponent.processPacket(AbstractComponent.java:236)
    at tigase.pubsub.PubSubComponent.processPacket(PubSubComponent.java:587)
    at tigase.server.AbstractMessageReceiver$QueueListener.run(AbstractMessageReceiver.java:1570)
Caused by: tigase.pubsub.repository.RepositoryException: User affiliations reading error
    at tigase.pubsub.repository.PubSubDAOJDBC.getUserSubscriptions(PubSubDAOJDBC.java:709)
    at tigase.pubsub.repository.PubSubDAOPool.getUserSubscriptions(PubSubDAOPool.java:398)
    at tigase.pubsub.modules.RetrieveSubscriptionsModule.process(RetrieveSubscriptionsModule.java:120)
    at tigase.component2.modules.ModulesManager.process(ModulesManager.java:114)
    at tigase.component2.AbstractComponent.processStanzaPacket(AbstractComponent.java:248)
    at tigase.component2.AbstractComponent.processPacket(AbstractComponent.java:236)
    at tigase.pubsub.PubSubComponent.processPacket(PubSubComponent.java:587)
    at tigase.server.AbstractMessageReceiver$QueueListener.run(AbstractMessageReceiver.java:1570)
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 92,442,450 milliseconds ago.  The last packet sent successfully to the server was 92,442,457 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
    at sun.reflect.GeneratedConstructorAccessor57.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
    at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1119)
    at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3318)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1940)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2113)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2693)
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2102)
    at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2261)
    at com.mysql.jdbc.CallableStatement.executeQuery(CallableStatement.java:912)
    at tigase.pubsub.repository.PubSubDAOJDBC.getUserSubscriptions(PubSubDAOJDBC.java:696)
    at tigase.pubsub.repository.PubSubDAOPool.getUserSubscriptions(PubSubDAOPool.java:398)
    at tigase.pubsub.modules.RetrieveSubscriptionsModule.process(RetrieveSubscriptionsModule.java:120)
    at tigase.component2.modules.ModulesManager.process(ModulesManager.java:114)
    at tigase.component2.AbstractComponent.processStanzaPacket(AbstractComponent.java:248)
    at tigase.component2.AbstractComponent.processPacket(AbstractComponent.java:236)
    at tigase.pubsub.PubSubComponent.processPacket(PubSubComponent.java:587)
    at tigase.server.AbstractMessageReceiver$QueueListener.run(AbstractMessageReceiver.java:1570)
Caused by: java.net.SocketException: Broken pipe (Write failed)
    at java.net.SocketOutputStream.socketWrite0(Native Method)
    at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:111)
    at java.net.SocketOutputStream.write(SocketOutputStream.java:155)
    at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
    at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
    at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3299)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1940)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2113)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2693)
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2102)
    at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2261)
    at com.mysql.jdbc.CallableStatement.executeQuery(CallableStatement.java:912)
    at tigase.pubsub.repository.PubSubDAOJDBC.getUserSubscriptions(PubSubDAOJDBC.java:696)
    at tigase.pubsub.repository.PubSubDAOPool.getUserSubscriptions(PubSubDAOPool.java:398)
    at tigase.pubsub.modules.RetrieveSubscriptionsModule.process(RetrieveSubscriptionsModule.java:120)
    at tigase.component2.modules.ModulesManager.process(ModulesManager.java:114)
    at tigase.component2.AbstractComponent.processStanzaPacket(AbstractComponent.java:248)
    at tigase.component2.AbstractComponent.processPacket(AbstractComponent.java:236)
    at tigase.pubsub.PubSubComponent.processPacket(PubSubComponent.java:587)
    at tigase.server.AbstractMessageReceiver$QueueListener.run(AbstractMessageReceiver.java:1570)

Replies (5)

Added by Andrzej Wójcik IoT 1 CloudTigaseTeam 2 months ago

This error suggests that there are some issues related to connecting to the MySQL database server from Tigase XMPP Server. Tigase if there are some issues will try to reconnect but will report errors anyway. Most likely after restarting Tigase those connectivity errors were resolved.

Added by Livia Yu 2 months ago

Hi @Andrzej Wójcik,

Thanks for your response. I know that restarting Tigase can solve the issue but I can not use it when the service formally launched.

I have used java decompiler to check the tigase-pubsub.jar and found when using the getUserSubscriptions function, it didnot actually check the DB connection at all.
But when using createNode function, it will use function checkConnection() to check&initRepo. Do u think if the checkConnection() will help to improve the issue?

   public Map<String, UsersSubscription> getUserSubscriptions(BareJID serviceJid, BareJID jid)
    throws RepositoryException
  {
    if (log.isLoggable(Level.FINEST)) {
      log.log(Level.FINEST, "Getting user subs: serviceJid: {0}, jid: {1}", new Object[] { serviceJid, jid });
    }
    try
    {
      ResultSet rs = null;
      Map result = new HashMap();
      synchronized (this.get_user_subscriptions_sp) {
        try {
          this.get_user_subscriptions_sp.setString(1, serviceJid.toString());
          this.get_user_subscriptions_sp.setString(2, jid.toString());
          rs = this.get_user_subscriptions_sp.executeQuery();
          while (rs.next()) {
            String nodeName = rs.getString(1);
            Subscription subscr = Subscription.valueOf(rs.getString(2));
            String subscrId = rs.getString(3);
            result.put(nodeName, new UsersSubscription(jid, subscrId, subscr));
          }
        } finally {
          release(null, rs);
        }
      }
      return result; } catch (SQLException e) {
    }
    throw new RepositoryException("User affiliations reading error", e);
  }


  public Long createNode(BareJID serviceJid, String nodeName, BareJID ownerJid, AbstractNodeConfig nodeConfig, NodeType nodeType, Long collectionId)
    throws RepositoryException
  {
    Long nodeId = null;
    try {
      ResultSet rs = null;
      String serializedNodeConfig = null;
      if (nodeConfig != null) {
        nodeConfig.setNodeType(nodeType);
        serializedNodeConfig = nodeConfig.getFormElement().toString();
      }

      checkConnection();
      synchronized (this.create_node_sp) {
        try {
          this.create_node_sp.setString(1, serviceJid.toString());
          this.create_node_sp.setString(2, nodeName);
          this.create_node_sp.setInt(3, nodeType.ordinal());
          this.create_node_sp.setString(4, ownerJid.toString());
          this.create_node_sp.setString(5, serializedNodeConfig);
          if (collectionId == null)
            this.create_node_sp.setNull(6, -5);
          else {
            this.create_node_sp.setLong(6, collectionId.longValue());
          }

          if (this.db_conn != null) {
            switch (1.$SwitchMap$tigase$db$DataRepository$dbTypes[this.database.ordinal()]) {
            case 1:
            case 2:
              this.create_node_sp.executeUpdate();
              Long localLong1 = getNodeId(serviceJid, nodeName);

              release(null, rs);

              return localLong1;
            }

            rs = this.create_node_sp.executeQuery();

            if (rs.next())
              nodeId = Long.valueOf(rs.getLong(1));
          }
        }
        finally {
          release(null, rs);
        }
      }
    } catch (SQLIntegrityConstraintViolationException e) {
      throw new RepositoryException("Error while adding node to repository, already exists?", e);
    } catch (SQLException e) {
      e.printStackTrace();
      throw new RepositoryException("Problem accessing repository.", e);
    }

    return nodeId;
  }

Added by Livia Yu 2 months ago

Hi Andrzej Wójcik,

Any suggestions?

Thanks.

Added by Andrzej Wójcik IoT 1 CloudTigaseTeam 2 months ago

Using checkConnection() could improve this implementation to make this code more resistant against database connectivity issue. However, an alternative approach is already used in Tigase XMPP Server 8.0.0 which will be released soon, so this improvement will not be released as a part of the next release of version 7.1.x.

Added by Livia Yu 2 months ago

Got it.

Thanks.

    (1-5/5)