Open mpet opened 1 year ago
Connecting via the Toxiproxy is something that you control, when you say to which host/port you want to connect in your service client.
Let's assume you have a MySQL service listening on port 3306 on localhost. Now, if you configure Toxiproxy like that:
Proxy mysqlProxy = client.createProxy("mysql", "localhost:21212", "localhost:3306");
you define the interface and port on which the Toxiproxy should bind, namely localhost:21212 and you define the upstream address to which the Toxiproxy should connect, namely localhost:3306.
Now, in your service client (e.g. mysql client), you need to use the localhost:21212
address. If you are able to connect with that address, you're connecting via Toxiproxy. It'll forward your traffic automatically to the second configured address, localhost:3306
.
But if you're using the original service address (and that's my suspicion after reading #100) in your client, e.g. localhost:3306, you're bypassing the Toxiproxy completely.
Hi
I changed to use your example:
netopeer2Proxy = toxiproxyClient.createProxy("netconfclient", "0.0.0.0:21212", HOSTNAME+":" + Netopeer2TestUtil.NETCONF_CALL_HOME_TLS_PORT);
Then I can see that my server is actually trying to connect to toxiproxy.
2023-02-21 15:09:40,025 (Wire.java:92) DEBUG : http-outgoing-3 << "[0x2][0x0][0x0][0x0][0x0][0x0][0x0];[INF]: LN: Call Home client "default-client" connecting...[\n]" 2023-02-21 15:09:40,025 (Wire.java:92) DEBUG : http-outgoing-3 << "[\r][\n]" 2023-02-21 15:09:40,025 (Slf4jLogConsumer.java:75) INFO : STDERR: [INF]: LN: Call Home client "default-client" connecting... 2023-02-21 15:09:40,025 (Wire.java:92) DEBUG : http-outgoing-3 << "ba[\r][\n]" 2023-02-21 15:09:40,025 (Wire.java:92) DEBUG : http-outgoing-3 << "[0x2][0x0][0x0][0x0][0x0][0x0][0x0]:[INF]: LN: Trying to connect via IPv4 to 127.0.0.1:21212.[\n]" 2023-02-21 15:09:40,025 (Wire.java:92) DEBUG : http-outgoing-3 << "[0x2][0x0][0x0][0x0][0x0][0x0][0x0]4[INF]: LN: getsockopt() error (Connection refused).[\n]" 2023-02-21 15:09:40,025 (Wire.java:92) DEBUG : http-outgoing-3 << "[0x2][0x0][0x0][0x0][0x0][0x0][0x0]4[INF]: LN: Trying to connect via IPv6 to ::1:21212.[\n]" 2023-02-21 15:09:40,025 (Wire.java:92) DEBUG : http-outgoing-3 << "[\r][\n]" 2023-02-21 15:09:40,025 (Wire.java:92) DEBUG : http-outgoing-3 << "47[\r][\n]" 2023-02-21 15:09:40,025 (Wire.java:92) DEBUG : http-outgoing-3 << "[0x2][0x0][0x0][0x0][0x0][0x0][0x0]?[ERR]: LN: connect() failed (Cannot assign requested address).[\n]" 2023-02-21 15:09:40,025 (Wire.java:92) DEBUG : http-outgoing-3 << "[\r][\n]" 2023-02-21 15:09:40,025 (Slf4jLogConsumer.java:75) INFO : STDERR: [INF]: LN: Trying to connect via IPv4 to 127.0.0.1:21212. 2023-02-21 15:09:40,025 (Slf4jLogConsumer.java:75) INFO : STDERR: [INF]: LN: getsockopt() error (Connection refused). 2023-02-21 15:09:40,025 (Slf4jLogConsumer.java:75) INFO : STDERR: [INF]: LN: Trying to connect via IPv6 to ::1:21212. 2023-02-21 15:09:40,026 (Slf4jLogConsumer.java:75) INFO : STDERR: [ERR]: LN: connect() failed (Cannot assign requested address).
It seems that the connection to toxiproxy is refused. Any ideas why?
@trekawek I also check with the server (Netopeer2) maintainer and he also concluded it is an issue with the proxy.
Hi,
How can I see if we connect via toxiProxy?
br,
//mike