by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Антон Колинько
    @AntKolinko_twitter

    ok, thanks. Will remove max.poll.interval.ms, so default time is used and remove this one auto.commit.interval.ms.

    What do you think about $message = $topic->consume($partition, 1000); <- what time it's better to set here?

    Paweł Niedzielski
    @steveb_gitlab
    @AntKolinko_twitter doesn't matter too much. This timeout is the maximum amount of time that this one particular call can wait. You should be able to safely increase it to like 10 seconds. It's use-case is for application that run with an event loop, so they can transfer control back to the loop. Since you're in a while(true) loop it doesn't matter that much.
    You're never really exiting the loop.
    abdo1
    @abdo1
    How to run kafka on different machines ?
    When i stop any one server then another one is able to send the details .
    Paweł Niedzielski
    @steveb_gitlab
    @abdo1 I don't really understand the question. Are you trying to run multiple Phprdkafka clients connected to the same topic?
    Wesley Willians
    @wesleywillians
    Hello Guys, I'm working with kafka and PHP and I need to make a sync request. I'm trying to use Request/Reply pattern, but I'm facing a problem. My consumer always have a delay to be connected so that my producer already sent the msg and it cant be read unless I read all data from the topic.. any insight? The idea is a kind of PubSub.
    btw, how can I get a current offset of a topic?
    Kamil Hurajt
    @kamilhurajt
    Hi Guys, I'm first time trying to use kafka as FIFO queue, as in company it's implemented. But I'm facing issue that by using High-Level consuming the service is waiting for mesage for 40 seconds!!! What I'm doing wrong ?
    Amy Luo
    @amyluo
    Is there a way I can synchronously produce messages in php-rdkafka library?
    Paweł Niedzielski
    @steveb_gitlab
    @amyluo just flush it immediately :D
    Aleksandar Aramov
    @alex687
    Hello guys, RdKafka\Conf::setDefaultTopicConf This function has been DEPRECATED. Where I should put Topic config? Inside RdKafka\Conf::set, should I use RdKafka\TopicConf class ? Thanks in advance.
    Paweł Niedzielski
    @steveb_gitlab
    @alex687 practically all configuration settings that have been available in TopicConf can be set in Conf object directly. Those that cannot can still be passed as TopicConf object to those classes that can receive it as argument (which is in practice all places that previously used it)
    Aleksandar Aramov
    @alex687
    @steveb_gitlab Thanks, I was wondering, because when I dump config ( config->dump()) it topic configs were not there.
    Paweł Niedzielski
    @steveb_gitlab
    @alex687 actually, there is an issue for something like that
    I'm not sure it applies
    Nick
    @nick-zh
    late to the party, but yeah @steveb_gitlab is right i opened this issue because of this :)
    Zakhar Morozov
    @fortael
    Hello. Is there any way to use truststore with SASL_SSL? I'm getting the error Java TrustStores are not supported, use 'ssl.ca.location' and a certificate file instead. when i use ssl.truststore.location
    Paweł Niedzielski
    @steveb_gitlab
    @fortael according to this comment from 2017 it's not https://github.com/edenhill/librdkafka/issues/1412#issuecomment-327403461
    and it's not really an issue with phprdkafka (or librdkafka actually)
    Zakhar Morozov
    @fortael
    I'm not quite understood you. Our java team use it in that configuration. So i expect php-extension able to do the same. I tried to use .pem file but the i got Java JAAS configuration is not supported too.
    Paweł Niedzielski
    @steveb_gitlab
    @fortael Java client is not the same as librdkafka (C library for Kafka client for all other languages - node, python, or in this case php)
    librdkafka itself does not support Java Truststores as the exception is telling you
    Zakhar Morozov
    @fortael
    Got it
    Paweł Niedzielski
    @steveb_gitlab
    Judging from the fact that the librdkafka community didn't implement it it's either proprietary and cannot be replicated to librdkafka, or it's complicated for some other reason
    but I'd say the former
    Paweł Niedzielski
    @steveb_gitlab
    btw @fortael
    see this discussion for possible solution for you: arnaud-lb/php-rdkafka#225
    BOR4
    @BOR4

    hey everyone!

    I am working on some very old legacy PHP project and I don't have much room to improve on stuff. We recently implemented sending to kafka and issue now is we have quite a lot of connections from PHP project to Kafka in TIME_WAIT.
    Unfortunately we are opening new connection for each request which is far for optimal. My questions is, is there some way to close TCP connection after flush().

    another questions is: can I somehow try utilize connection.max.idle.ms for producing messages?
    Nick
    @nick-zh
    heya
    I think freeing the producer (setting it to null) probably will do the trick. also if you are pre librdkafka:1.0, this might too:
    https://github.com/arnaud-lb/php-rdkafka#socketblockingmaxms-librdkafka--100
    from 1.x onward this is not necessary anymore
    if destroying the producer object is not an option connections.max.idle.ms can maybe used to achieve this too but i haven't tried it.
    BOR4
    @BOR4
    thank you Nick I will try it!
    alexandra-default
    @alexandra-default

    Good day everyone!
    I am trying to test out this library, but have strange behaviour on high-level consumer, default auto rebalancing in specific. I suppose there are some mistakes with Conf() settings, but have troubles with debugging on my own, can you help me out?
    We using Docker for local tests. There are eight partitions in the topic. While consuming messages with 4 sec timeout Consumer provides this info:

    [17:39:16][partition 0] Timed out [key: '' offset: 0]
    [17:39:20][partition 0] Timed out [key: '' offset: 0]
    [17:39:20][partition 4] No more messages; will wait for more [key: '' offset: 14]
    [17:39:24][partition 0] Timed out [key: '' offset: 0]
    [17:39:28][partition 0] Timed out [key: '' offset: 0]
    [17:39:32][partition 0] Timed out [key: '' offset: 0]
    [17:39:36][partition 0] Timed out [key: '' offset: 0]
    [17:39:40][partition 0] Timed out [key: '' offset: 0]
    [17:39:44][partition 0] Timed out [key: '' offset: 0]
    [17:39:48][partition 0] Timed out [key: '' offset: 0]
    [17:39:52][partition 0] Timed out [key: '' offset: 0]
    [17:39:56][partition 0] Timed out [key: '' offset: 0]
    [17:40:00][partition 0] Timed out [key: '' offset: 0]
    [17:40:04][partition 0] Timed out [key: '' offset: 0]
    [17:40:08][partition 0] Timed out [key: '' offset: 0]
    [17:40:12][partition 0] Timed out [key: '' offset: 0]
    [17:40:16][partition 0] Timed out [key: '' offset: 0]
    [17:40:20][partition 0] Timed out [key: '' offset: 0]
    [17:40:24][partition 0] Timed out [key: '' offset: 0]
    [17:40:28][partition 0] Timed out [key: '' offset: 0]
    [17:40:32][partition 0] Timed out [key: '' offset: 0]
    [17:40:36][partition 0] Timed out [key: '' offset: 0]

    Why Consumer sticks only to partition 0 with timeout error although there are other seven partitions, even with successful consuming?

    Here is current Conf() state
    $this->config = new Conf();
    $this->config->set('topic.metadata.refresh.interval.ms', env('KAFKA_REFRESH_INTERVAL_MSEC')); // 10000
    $this->config->set('metadata.broker.list', env('KAFKA_BROKER_LIST'));
    $this->config->set('auto.offset.reset', 'largest');
    $this->config->set('enable.partition.eof', 'true');
    Nick
    @nick-zh
    heya
    can you elaborte a bit more, so are messages actually not being consumed or are you just wondering, after consumption, why it sticks to partition 0?
    Nick
    @nick-zh
    Ok, so i checked the code, librdkafka actually returns null on timeout, so the 0 is coming from us (the extension, 99% sure), so you can ignore the partition info on this "error" since we don't have that info, i will check if we can improve this, so partition is NULL. If your concern is, that the consumer is not "jumping" around and picking up new messages from other partitions, no worries, works like a charm ;)
    Nick
    @nick-zh
    PR is created ;) should be fixed soon(ish) :D
    alexandra-default
    @alexandra-default

    Oh, thanks a lot! You are awesome with fast responding =)

    so are messages actually not being consumed

    Yeah, this is the case. I am 100% sure there are messages in the topic for each partition (check it with Kafdrop/Kafkamanager), but consumer skips most of them with an error, very rarely successfully consuming a message. There is a single consumer for the topic within a group:

    $this->config->set('group.id', 'kafka_consumer_group_' . $topic);

    I add a rebalance callback as documented example stated for logging partition assign and got this:

    [10:46:41] Timed out
    [10:46:45] Timed out
    Assign: array(1) {
      [0]=>
      object(RdKafka\TopicPartition)#483 (3) {
        ["topic"]=>
        string(9) "test"
        ["partition"]=>
        int(0)
        ["offset"]=>
        int(-1001)
      }
    }
    [10:46:46][partition 0] No more messages; will wait for more [key: '' offset: 22]
    [10:46:50] Timed out
    [10:46:54] Timed out
    [10:46:58] Timed out
    [10:47:02] Timed out
    [10:47:06] Timed out

    I wonder if there are problems with offsets (I use auto.offset.reset = largest).

    Nick
    @nick-zh
    most certainly, earliest means: for the very first time, start at the beginning, latest means: for the very first time, start at the end
    so in your case you are only consuming new messages.
    Nick
    @nick-zh
    if you have already commited offsets, you need to use a new consumer group to get all the messages
    and maybe for futher explenation, timed out is not really an error (more of a soft error), just means in your timeout there was no message to consume,
    high level consumer balancing can take a few seconds in the beginning
    alexandra-default
    @alexandra-default

    so in your case you are only consuming new messages

    Yes, this is intended. New messages are published in the topic (after consumer start), but consumer don't consume then at all except rare cases, even after few minutes, so I don't think this error isn't applicable. I don't understand why sometimes message are consumed successfully (so this means Kafka setting are correct, right?), but mostly there are only errors.

    How can I debug what is the problem behind 'Timed out' (like, is there is problem with connection, group default settings, maybe I need to switch to low-level consumer). Is there any data I can provide?

    Maybe there is no problem with this library, but with behaviour of librdkafka itself?
    Nick
    @nick-zh
    first of all it would be helpfull to know:
    • version of rdkafka
    • version of librdkafka
      it's also hard for me to tell, since it could be related to either producer or consumer. the default log level that is in place should be enough to see broker errors.
      timeout really isn't an error, just means, that there were no more messages to read
      if you see any other errors, please let me know
    alexandra-default
    @alexandra-default
    We use
    librdkafka version (runtime) => 1.1.0
    librdkafka version (build) => 1.1.0.255
    
    ...
    
    echo phpversion('rdkafka');
    4.0.0-dev
    Nick
    @nick-zh
    ok, so if you set setDrMsgCb for your producer, you can check if the message was truly sent to rule this out as the source of delay

    if you need more debugging on consumer side add this:

    $conf->set('debug', 'consumer,cgrp,topic,fetch');

    additionally you could also up the log level (default: 6):

    $conf->set('log_level', '7');
    alexandra-default
    @alexandra-default
    That is so nice of you to provide settings, thanks!
    So there are errors with offset:
    %7|1575541711.847|JOIN|rdkafka#consumer-1| [thrd:main]: Group "kafka_consumer_group_test": join with 1 (1) subscribed topic(s)
    %7|1575541711.847|CGRPMETADATA|rdkafka#consumer-1| [thrd:main]: consumer join: metadata for subscription is up to date (1991ms old)
    %7|1575541711.847|JOIN|rdkafka#consumer-1| [thrd:main]: kafka:9092/1001: Joining group "kafka_consumer_group_test" with 1 subscribed topic(s)
    %7|1575541711.847|CGRPJOINSTATE|rdkafka#consumer-1| [thrd:main]: Group "kafka_consumer_group_test" changed join state init -> wait-join (v1, state up)
    %7|1575541713.847|COMMIT|rdkafka#consumer-1| [thrd:main]: OffsetCommit internal error: Local: No offset stored
    %7|1575541713.847|COMMIT|rdkafka#consumer-1| [thrd:main]: OffsetCommit for -1 partition(s): cgrp auto commit timer: returned: Local: No offset stored
    %7|1575541713.847|UNASSIGN|rdkafka#consumer-1| [thrd:main]: Group "kafka_consumer_group_test": unassign done in state up (join state wait-join): without new assignment: OffsetCommit done (__NO_OFFSET)
    %7|1575541718.847|COMMIT|rdkafka#consumer-1| [thrd:main]: OffsetCommit internal error: Local: No offset stored
    %7|1575541718.847|COMMIT|rdkafka#consumer-1| [thrd:main]: OffsetCommit for -1 partition(s): cgrp auto commit timer: returned: Local: No offset stored
    %7|1575541718.847|UNASSIGN|rdkafka#consumer-1| [thrd:main]: Group "kafka_consumer_group_test": unassign done in state up (join state wait-join): without new assignment: OffsetCommit done (__NO_OFFSET)
    [13:28:38] Timed out
    Nick
    @nick-zh
    is there any consumer code you can provide so i can check this out?