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

Docker Event subscribe no messages #5980

Closed
iBugCode opened this issue Aug 30, 2024 · 8 comments
Closed

Docker Event subscribe no messages #5980

iBugCode opened this issue Aug 30, 2024 · 8 comments

Comments

@iBugCode
Copy link

Lite FullNode

# docker-compose.yml
version: '3.8'

services:
    java-tron-node:
        container_name: java-tron-node
        image: tronprotocol/java-tron
        restart: always
        networks:
            - eth-network
        volumes:
            - ./data/config:/java-tron/config
            - ./data/output-directory:/java-tron/output-directory
            - ./data/logs:/java-tron/logs
        ports:
            - 8090:8090
            - 18888:18888
            - 5555:5555
        command: "-c /java-tron/config/main_net_config.conf --es"
# main_net_config.conf
node {
    ......
    openHistoryQueryWhenLiteFN = true
    ......
}

event.subscribe = {
    native = {
        useNativeQueue = true
        bindport = 5555
        sendqueuelength = 1000
    }

    topics = [
        {
          triggerName = "block"
          enable = ture
          topic = "block"
          solidified = false
        },
        ......
    ]
}
// zeromq.js
var zmq = require("zeromq");
var sock = zmq.socket("sub");

sock.connect("tcp://127.0.0.1:5555");
// sock.subscribe("*");
// sock.subscribe("blockTrigger");
sock.subscribe("block");
console.log("Subscriber connected to port 5555");

sock.on("message", function(topic, message) {
    console.log(
        "received a message related to:",
        Buffer.from(topic).toString(),
        ", containing message:",
        Buffer.from(message).toString()
    );
});

response Subscriber connected to port 5555
No other messages
Thanks!

@endiaoekoe
Copy link

No other messages

@iBugCode
seems like it is due to a spelling error in main_net_config.conf.
image
which result in event subscribe for topic 'block' does not work.

@sproot
Copy link

sproot commented Aug 30, 2024

I have a similar issue. I'm running Full Node and I can get block and transaction events only.
I'm also running node in docker. And using native (zeromq) event queue.
None of the contractevent or contractlog events are coming. The node is fully synced, topics enabled of course.
There must be someting obvious I'm missing.

@sproot
Copy link

sproot commented Aug 31, 2024

Yeah, should be sock.subscribe('contractEvent) and sock.subscribe('contractLog') both in camel case instead of sock.subscribe('contractevent) and sock.subscribe('contractlog). The latter if how they named in config. Using camelCase is not obvious. Maybe this should be added to the docs.

@317787106
Copy link
Contributor

@sproot you can set the enable = true for all 7 topics. And don't use sock.subscribe("xxx"); So you can get anything and filter as your purpose.

@NathanHo1024
Copy link

sproot

it doesn't work for me. i change the
topics = [ { triggerName = "block" enable = true topic = "block" }, ...... ] all be true. and i filter the contract-address and log-topic . and i set sock.subscribe('contractEvent) to my js-script. but it's still nothing happen.

@NathanHo1024
Copy link

@sproot you can set the enable = true for all 7 topics. And don't use sock.subscribe("xxx"); So you can get anything and filter as your purpose.

兄弟。过滤条件不起作用啊。我全部都设置为ture了。 只有block的订阅才有输出。 改成订阅contractevent 或者contractEvent 都毫无用处。

@317787106
Copy link
Contributor

@NathanHo1024 @sproot I can get all the events using python:

# encoding:utf-8

import zmq

if __name__ == "__main__":
    context = zmq.Context()
    socket = context.socket(zmq.SUB)
    socket.connect("tcp://localhost:5555")
    socket.setsockopt(zmq.SUBSCRIBE, ''.encode('utf-8'))  
    while True:
        response = socket.recv().decode('utf-8')
        print("response: %s" % response)

using the following config:

event.subscribe = {
  native = {
    useNativeQueue = true // if true, use native message queue, else use event plugin.
    bindport = 5555 // bind port
    sendqueuelength = 1000 //max length of send queue
  }

  path = "" // absolute path of plugin
  server = "" // target server address to receive event triggers
  dbconfig = "" // dbname|username|password
  contractParse = true,
  topics = [
      {
        triggerName = "block" // block trigger, the value can't be modified
        enable = true
        topic = "block" // plugin topic, the value could be modified
        solidified = false // if set true, just need solidified block, default is false
      },
      {
        triggerName = "transaction"
        enable = true
        topic = "transaction"
        solidified = false
        ethCompatible = false // if set true, add transactionIndex, cumulativeEnergyUsed, preCumulativeLogCount, logList, energyUnitPrice, default is false
      },
      {
        triggerName = "contractevent"
        enable = true
        topic = "contractevent"
      },
      {
        triggerName = "contractlog"
        enable = true
        topic = "contractlog"
        redundancy = true // if set true, contractevent will also be regarded as contractlog
      },
      {
        triggerName = "solidity" // solidity block trigger(just include solidity block number and timestamp), the value can't be modified
        enable = true            // the default value is true
        topic = "solidity"
      },
      {
        triggerName = "solidityevent"
        enable = true
        topic = "solidityevent"
      },
      {
        triggerName = "soliditylog"
        enable = true
        topic = "soliditylog"
        redundancy = true // if set true, solidityevent will also be regarded as soliditylog
      }
  ]

  filter = {
    fromblock = "" // the value could be "", "earliest" or a specified block number as the beginning of the queried range
    toblock = "" // the value could be "", "latest" or a specified block number as end of the queried range
    contractAddress = [
      "" // contract address you want to subscribe, if it's set to "", you will receive contract logs/events with any contract address.
    ]

    contractTopic = [
      "" // contract topic you want to subscribe, if it's set to "", you will receive contract logs/events with any contract topic.
    ]
  }
}

@vivian1912
Copy link
Contributor

@iBugCode May I ask if this issue has been resolved? If yes, this issue will be closed later and please feel free to re-open it if you still see the issue, thanks.

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

No branches or pull requests

6 participants