<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">Check this, i removed the code from my responder by now but it was something like this<div><br></div><div><div><div style="color: rgb(54, 54, 54); background-color: rgb(255, 255, 255); font-family: Menlo, Monaco, Consolas, "Lucida Console", "Roboto Mono", "Courier New", monospace, Menlo, Monaco, "Courier New", monospace; font-size: 15.6px; line-height: 23px; white-space: pre;"><div><span style="color: rgb(63, 151, 223);">func</span> main<span style="color: rgb(44, 44, 44);">()</span> <span style="color: rgb(44, 44, 44);">{</span></div><div> l<span style="color: rgb(44, 44, 44);">,</span> err <span style="color: rgb(44, 44, 44);">:=</span> net<span style="color: rgb(44, 44, 44);">.</span>ListenUnix<span style="color: rgb(44, 44, 44);">(</span><span style="color: rgb(162, 86, 55);">"unix"</span><span style="color: rgb(44, 44, 44);">,</span> <span style="color: rgb(44, 44, 44);">&</span>UnixAddr<span style="color: rgb(44, 44, 44);">{</span>Name<span style="color: rgb(44, 44, 44);">:</span> <span style="color: rgb(162, 86, 55);">"unix"</span><span style="color: rgb(44, 44, 44);">,</span>Net <span style="color: rgb(44, 44, 44);">:</span><span style="color: rgb(162, 86, 55);">"/tmp/echo.sock"</span><span style="color: rgb(44, 44, 44);">,})</span></div><div> <span style="color: rgb(63, 151, 223);">if</span> err <span style="color: rgb(44, 44, 44);">!=</span> <span style="color: rgb(63, 151, 223);">nil</span> <span style="color: rgb(44, 44, 44);">{</span></div><div> panic<span style="color: rgb(44, 44, 44);">(</span>err<span style="color: rgb(44, 44, 44);">)</span></div><div> <span style="color: rgb(44, 44, 44);">}</span></div><br><div> <span style="color: rgb(63, 151, 223);">for</span> <span style="color: rgb(44, 44, 44);">{</span></div><div> fd<span style="color: rgb(44, 44, 44);">,</span> err <span style="color: rgb(44, 44, 44);">:=</span> l<span style="color: rgb(44, 44, 44);">.</span>Accept<span style="color: rgb(44, 44, 44);">()</span></div><div> <span style="color: rgb(63, 151, 223);">if</span> err <span style="color: rgb(44, 44, 44);">!=</span> <span style="color: rgb(63, 151, 223);">nil</span> <span style="color: rgb(44, 44, 44);">{</span></div><div> panic<span style="color: rgb(44, 44, 44);">(</span>err<span style="color: rgb(44, 44, 44);">)</span></div><div> <span style="color: rgb(44, 44, 44);">}</span></div><br><div> <span style="color: rgb(63, 151, 223);">go</span> <span style="color: rgb(63, 151, 223);">func</span><span style="color: rgb(44, 44, 44);">(</span>fd net<span style="color: rgb(44, 44, 44);">.</span>Conn<span style="color: rgb(44, 44, 44);">)</span> <span style="color: rgb(44, 44, 44);">{</span> </div><div> <span style="color: rgb(63, 151, 223);">var</span> buf <span style="color: rgb(44, 44, 44);">[</span><span style="color: rgb(73, 104, 57);">1024</span><span style="color: rgb(44, 44, 44);">]</span><span style="color: rgb(63, 151, 223);">byte</span></div><div> n<span style="color: rgb(44, 44, 44);">,</span> err <span style="color: rgb(44, 44, 44);">:=</span> fd<span style="color: rgb(44, 44, 44);">.</span>Read<span style="color: rgb(44, 44, 44);">(</span>buf<span style="color: rgb(44, 44, 44);">)</span></div><div> <span style="color: rgb(63, 151, 223);">if</span> err<span style="color: rgb(44, 44, 44);">!=</span><span style="color: rgb(63, 151, 223);">nil</span><span style="color: rgb(44, 44, 44);">{</span></div><div> panic<span style="color: rgb(44, 44, 44);">(</span>err<span style="color: rgb(44, 44, 44);">)</span></div><div> <span style="color: rgb(44, 44, 44);">}</span></div><div> data <span style="color: rgb(44, 44, 44);">:=</span> buf<span style="color: rgb(44, 44, 44);">[</span><span style="color: rgb(73, 104, 57);">0</span><span style="color: rgb(44, 44, 44);">:</span>netip<span style="color: rgb(44, 44, 44);">]</span></div><div> println<span style="color: rgb(44, 44, 44);">(</span><span style="color: rgb(162, 86, 55);">"Server got:"</span><span style="color: rgb(44, 44, 44);">,</span> <span style="color: rgb(63, 151, 223);">string</span><span style="color: rgb(44, 44, 44);">(</span>data<span style="color: rgb(44, 44, 44);">))</span></div><div> _<span style="color: rgb(44, 44, 44);">,</span> err <span style="color: rgb(44, 44, 44);">=</span> c<span style="color: rgb(44, 44, 44);">.</span>Write<span style="color: rgb(44, 44, 44);">(</span>data<span style="color: rgb(44, 44, 44);">)</span></div><div> <span style="color: rgb(63, 151, 223);">if</span> err <span style="color: rgb(44, 44, 44);">!=</span> <span style="color: rgb(63, 151, 223);">nil</span> <span style="color: rgb(44, 44, 44);">{</span></div><div> panic<span style="color: rgb(44, 44, 44);">(</span>err<span style="color: rgb(44, 44, 44);">)</span></div><div> <span style="color: rgb(44, 44, 44);">}</span></div><div> <span style="color: rgb(44, 44, 44);">}(</span>fd<span style="color: rgb(44, 44, 44);">)</span><span style="color: rgb(44, 44, 44); font-size: 15.6px;">}</span></div><div><span style="color: rgb(44, 44, 44);">}</span></div></div></div><div><br></div><div>Using this (tested with pdns as client, a python cliend pasted below, a golang client and also netcat) causes</div><div><br></div><div>1. i can connect</div><div>2. i can send a message and it’s printed</div><div>3. answer is received</div><div>4. complete lock, im not able to send any other message (yes, starting a different instance of any client sends another message and locks and so on)</div><div><br></div><div>If i add (right before }(fd)} (inside the for loop) an “fd.Close()” what happens is, there’s no lock anymore, i can send messages over and over again, but (the famous but) doesn’t matter which client i use (python, pdns, golang, java) i need to start the client everytime.</div><div><br></div><div>Example</div><div><br></div><div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">import socket</div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">import sys</div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">import time</div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">import json</div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"><br></div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">with socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM) as client:</div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"> client.connect("/tmp/pra.sock")</div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"><br></div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"> while True:</div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"> client.send(json.dumps({'method':'initialize'}).encode('utf-8'))</div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"> v = client.recv(1024)</div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"> print(f"--> {v}")</div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"> time.sleep(1)</div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"><br></div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"> client.close()</div></div><div><br></div><div>Scenario 1 (without the fd.Close())</div><div>Starting this, only sends and receive first message and locks</div><div><br></div><div>Scenario 2 (with fd.Close())</div><div>Starting this, sends and receives first message and throws an Exception because Broken Pipe</div><div><br></div><div>You can see im moving the read/answer to a different coroutine on every call to avoid blocking the socket in anyway but it doesnt help.</div><div><br></div><div>Note:</div><div>Using SOCKET_DGRAM i was able to loop for ever with no problem, i tried to set that in <a href="http://unixconnector.cc">unixconnector.cc</a> changing the socket type but is not that simple.</div><div><br></div><div>Note 2:</div><div>Helped a lot what you told me, i wrote a simple python script to stress the responder (putting pdns aside, only pcap’d real traffic to have real queries for my script) and i found something interesting, as more threads i open pushing the responder, there’s queries that takes more and more time to be answered, a good reason for the http connection between pdns > backend fails with timeout and DNS client see no responses. im working on that right now. nevertheless i would like to have the option of unixsockets if possible for different small scenarios (example, a single pod containing pdns+backend+redis+mongo) able to be replicated a few times in a small K8 cluster.</div><div><br></div><div>Hope it helps</div><div><br></div><div><br></div><div><br></div><div><br id="lineBreakAtBeginningOfMessage"><div><br><blockquote type="cite"><div>On 30 Nov 2023, at 05:18, Remi Gacogne via Pdns-users <pdns-users@mailman.powerdns.com> wrote:</div><br class="Apple-interchange-newline"><div><div>On 29/11/2023 01:07, Alexis Fidalgo wrote:<br><blockquote type="cite">Problem is (and i’ve testing with golang and python) after the answer the “initialize” message, the socket is closed, so, getAllDomains message is being sent using a closed socket and that’s why i don’t see it on the responder side and pdns does not receive and answer, polls 2 times and reaches timeout.<br></blockquote><br>Why do you think the socket is closed? It doesn't show up in your previous strace log, and poll() wouldn't not time out but immediately return an error if the socket had been closed.<br><br><blockquote type="cite">i can see there’s no test for unixsocket in the source tree.<br></blockquote><br>There is such a test in test-remotebackend-unix.cc<br><br>-- <br>Remi Gacogne<br>PowerDNS.COM BV - https://www.powerdns.com/<br><br>_______________________________________________<br>Pdns-users mailing list<br>Pdns-users@mailman.powerdns.com<br>https://mailman.powerdns.com/mailman/listinfo/pdns-users<br></div></div></blockquote></div><br></div></div></body></html>