wangduanduan created an issue (kamailio/kamailio#4198)
<!-- Kamailio Project uses GitHub Issues only for bugs in the code or feature requests. Please use this template only for bug reports.
If you have questions about using Kamailio or related to its configuration file, ask on sr-users mailing list:
* https://lists.kamailio.org/mailman3/postorius/lists/sr-users.lists.kamailio....
If you have questions about developing extensions to Kamailio or its existing C code, ask on sr-dev mailing list:
* https://lists.kamailio.org/mailman3/postorius/lists/sr-dev.lists.kamailio.or...
Please try to fill this template as much as possible for any issue. It helps the developers to troubleshoot the issue.
Note that an issue report may be closed automatically after about 2 months if there is no interest from developers or community users on pursuing it, being considered expired. In such case, it can be reopened by writing a comment that includes the token `/notexpired`. About two weeks before considered expired, the issue is marked with the label `stale`, trying to notify the submitter and everyone else that might be interested in it. To remove the label `stale`, write a comment that includes the token `/notstale`. Also, any comment postpone the `expire` timeline, being considered that there is interest in pursuing the issue.
If there is no content to be filled in a section, the entire section can be removed.
You can delete the comments from the template sections when filling.
You can delete next line and everything above before submitting (it is a comment). -->
### Description
kafka_send in event_route like tcp:timeout, tcp:closed not work
``` event_route[tcp:closed] { if (kafka_send("my_topic", "tcp:closed")) { xlog("L_INFO", "send success tcp:closed"); } } event_route[tcp:timeout] { if (kafka_send("my_topic", "tcp:timeout")) { xlog("L_INFO", "send success tcp:timeout"); } } ```
in log, its show "send success tcp:closed", "send success tcp:timeout", but in kafka web ui, in the **my_topic**, can't find the "tcp:closed" or " tcp:timeout" message.
--- but if the kafka_send in onreply_route, message will be send ok, in the kafka web ui, the "some_route" can be find.
``` onreplay_route[some_route]{ if (kafka_send("my_topic", "some_routet")) { xlog("L_INFO", "send success some_routet"); } } ```
<!-- Explain what you did, what you expected to happen, and what actually happened. -->
### Troubleshooting
#### Reproduction
<!-- If the issue can be reproduced, describe how it can be done. -->
#### Debugging Data
<!-- If you got a core dump, use gdb to extract troubleshooting data - full backtrace, local variables and the list of the code at the issue location.
gdb /path/to/kamailio /path/to/corefile bt full info locals list
If you are familiar with gdb, feel free to attach more of what you consider to be relevant. -->
``` (paste your debugging data here) ```
#### Log Messages
<!-- Check the syslog file and if there are relevant log messages printed by Kamailio, add them next, or attach to issue, or provide a link to download them (e.g., to a pastebin site). -->
``` (paste your log messages here) ```
#### SIP Traffic
i use tcpdump to capture the traffic between kamailio and kafka. - when use kafka_send in event_route, no packages captured.
<!-- If the issue is exposed by processing specific SIP messages, grab them with ngrep or save in a pcap file, then add them next, or attach to issue, or provide a link to download them (e.g., to a pastebin site). -->
```
```
### Possible Solutions
<!-- If you found a solution or workaround for the issue, describe it. Ideally, provide a pull request with a fix. -->
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
``` 5.6.1 ```
* **Operating System**: centos7
<!-- Details about the operating system, the type: Linux (e.g.,: Debian 8.4, Ubuntu 16.04, CentOS 7.1, ...), MacOS, xBSD, Solaris, ...; Kernel details (output of `lsb_release -a` and `uname -a`) -->
``` (paste your output here) ```
linuxmaniac left a comment (kamailio/kamailio#4198)
5.6.1 is no longer supported. Try a recent version, please
wangduanduan left a comment (kamailio/kamailio#4198)
tcp:closed, tcp:reset tcp:timeout will running tcp main process.
but in tcp main process, kafka not initing,
wangduanduan left a comment (kamailio/kamailio#4198)
[ if(rank != PROC_TIMER && rank <= PROC_MAIN)](https://github.com/kamailio/kamailio/blob/7314fbcc6fb7c211817d1660b98deaf9db...)
so kafka_send() can not use in event_route[tcp:closed], event_route[tcp:reset], event_route[tcp:timeout]
wangduanduan left a comment (kamailio/kamailio#4198)
in 5.6 https://github.com/kamailio/kamailio/blob/144b61dc9e66f574e6a32a7dcd3b3e3e13...
henningw left a comment (kamailio/kamailio#4198)
As mentioned already, please try a maintained version, e.g. 5.8.6.
wangduanduan left a comment (kamailio/kamailio#4198)
i have try 6.0.1, the kafka_send also not work in event_route[tcp:closed]
28(89) DEBUG: <core> [core/tcp_main.c:3717]: tcp_emit_closed_event(): TCP closed event creation triggered (reason: 1) 28(89) DEBUG: tcpops [tcpops.c:311]: tcpops_handle_tcp_closed(): received TCP closed event 28(89) DEBUG: tcpops [tcpops.c:252]: tcpops_tcp_closed_run_route(): event reason id: 1 28(89) ERROR: <script>: tcp:timeout 28(89) ERROR: kafka [kfk.c:883]: kfk_message_send(): kafka module is unusable: no kafka object! Skip sending message, message lost!28(89) DEBUG: kafka [kfk.c:853]: kfk_topic_get(): Topic name match: kamailio_event_bus 28(89) ERROR: kafka [kfk.c:892]: kfk_message_send(): kafka module is unusable: child init NOT ok! Skip sending message, message lost!28(89) DEBUG: kafka [kfk.c:1083]: kfk_stats_add(): Adding stats: (topic: kamailio_event_bus) (error: -172) 28(89) DEBUG: kafka [kfk.c:1096]: kfk_stats_add(): General stats: total = 5 error = 4 28(89) DEBUG: kafka [kfk.c:1101]: kfk_stats_add(): Topic search: kamailio_event_bus 28(89) DEBUG: kafka [kfk.c:1108]: kfk_stats_add(): Topic match: kamailio_event_bus 28(89) DEBUG: kafka [kfk.c:1144]: kfk_stats_add(): Topic stats (kamailio_event_bus): total = 5 error = 4 28(89) ERROR: kafka [kafka_mod.c:231]: w_kafka_send(): Cannot send kafka (topic: kamailio_event_bus) message: tcp:timeout
wangduanduan left a comment (kamailio/kamailio#4198)
kamailio 5.8.6 kafka_send in event_route tcp:closed not work too.
stefan-mititelu-idt left a comment (kamailio/kamailio#4198)
@wangduanduan kafka object init is excluded for PROC_TCP_MAIN main process, and was like that in older kamailio versions too.
I remember was noticing coredump happening sometimes, on "systemctl kamailio stop", due to librdkafka ssl connection, when init kafka object in lower rank, non worker processes. Not sure if that's the case for exactly PROC_TCP_MAIN. I was mainly interested in using it in timer proc and routing processes.
I think you can include PROC_TCP_MAIN and do some testing. Please also try use kafka sasl connection when testing. If no coredumps spotted, I think you can include it in a PR.