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

when protocol is like mysql, should connection to server after tcp connected? because mysql is server send first package #33

Open
huanghuangzym opened this issue Feb 8, 2022 · 0 comments

Comments

@huanghuangzym
Copy link
Member

i write a mysql codec

admin:
access_log_path: ./envoy_debug.log
address:
socket_address:
address: 127.0.0.1
port_value: 8080
static_resources:
listeners:
name: listener_meta_protocol
address:
socket_address:
address: 0.0.0.0
port_value: 3306
filter_chains:
- filters:
- name: aeraki.meta_protocol_proxy
typed_config:
'@type': type.googleapis.com/aeraki.meta_protocol_proxy.v1alpha.MetaProtocolProxy
application_protocol: mysql
codec:
name: aeraki.meta_protocol.codec.mysql
metaProtocolFilters:
- name: aeraki.meta_protocol.filters.router
routeConfig:
routes:
- name: default
match:
metadata:
- name: method
exact_match: sayHello
route:
cluster: outbound|9090||mysql.testhl.svc.cluster.local
statPrefix: outbound|9090||mysql.testhl.svc.cluster.local
clusters:
name: outbound|9090||mysql.testhl.svc.cluster.local
type: STATIC
connect_timeout: 5s
load_assignment:
cluster_name: outbound|9090||mysql.testhl.svc.cluster.local
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: 10.97.54.132
port_value: 3306

used this config to test it

then debug it
it seems when the tcp connection connected, the server will not connect to upstream
but protocol like mysql ,the first package is sent by server?
how to solve this problem?
when downstream connected, why not connect to upstream?

[root@huangli-k8s:/root]tcpdump -i cni0 tcp port 3306 -s 0 -vv
tcpdump: listening on cni0, link-type EN10MB (Ethernet), capture size 262144 bytes
16:23:25.244400 IP (tos 0x0, ttl 64, id 27261, offset 0, flags [DF], proto TCP (6), length 60)
huangli-k8s.22028 > 10.244.0.169.mysql: Flags [S], cksum 0x16c0 (incorrect -> 0xbe32), seq 910018611, win 64240, options [mss 1460,sackOK,TS val 385023985 ecr 0,nop,wscale 7], length 0
16:23:25.244424 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 60)
10.244.0.169.mysql > huangli-k8s.53302: Flags [S.], cksum 0xc387 (incorrect -> 0x1ed7), seq 1108886376, ack 910018612, win 64308, options [mss 1410,sackOK,TS val 1062450034 ecr 385023985,nop,wscale 7], length 0
16:23:25.244436 IP (tos 0x0, ttl 64, id 27262, offset 0, flags [DF], proto TCP (6), length 52)
huangli-k8s.22028 > 10.244.0.169.mysql: Flags [.], cksum 0x16b8 (incorrect -> 0x6da2), seq 910018612, ack 1108886377, win 502, options [nop,nop,TS val 385023985 ecr 1062450034], length 0
16:23:25.244532 IP (tos 0x8, ttl 64, id 35959, offset 0, flags [DF], proto TCP (6), length 130)
10.244.0.169.mysql > huangli-k8s.53302: Flags [P.], cksum 0xc3cd (incorrect -> 0x4ca8), seq 1:79, ack 1, win 503, options [nop,nop,TS val 1062450034 ecr 385023985], length 78
16:23:25.244542 IP (tos 0x0, ttl 64, id 27263, offset 0, flags [DF], proto TCP (6), length 52)
huangli-k8s.22028 > 10.244.0.169.mysql: Flags [.], cksum 0x16b8 (incorrect -> 0x6d54), seq 0, ack 79, win 502, options [nop,nop,TS val 385023985 ecr 1062450034], length 0
16:23:25.244577 IP (tos 0x0, ttl 64, id 27264, offset 0, flags [DF], proto TCP (6), length 239)
huangli-k8s.22028 > 10.244.0.169.mysql: Flags [P.], cksum 0x1773 (incorrect -> 0x4b07), seq 0:187, ack 79, win 502, options [nop,nop,TS val 385023985 ecr 1062450034], length 187
16:23:25.244590 IP (tos 0x8, ttl 64, id 35960, offset 0, flags [DF], proto TCP (6), length 52)
10.244.0.169.mysql > huangli-k8s.53302: Flags [.], cksum 0xc37f (incorrect -> 0x45a7), seq 79, ack 188, win 502, options [nop,nop,TS val 1062450034 ecr 385023985], length 0

[2022-02-08 16:24:16.754][9311][debug][main] [external/envoy/source/server/server.cc:209] flushing stats
[2022-02-08 16:24:21.758][9311][debug][main] [external/envoy/source/server/server.cc:209] flushing stats
[2022-02-08 16:24:22.343][9406][debug][filter] [./src/application_protocols/mysql/mysql_codec.h:186] mysql: begin to construct
[2022-02-08 16:24:22.343][9406][debug][filter] [src/meta_protocol_proxy/conn_manager.cc:55] meta protocol: onNewConnection
[2022-02-08 16:24:22.343][9406][debug][conn_handler] [external/envoy/source/server/active_tcp_listener.cc:328] [C0] new connection
[2022-02-08 16:24:22.343][9406][trace][connection] [external/envoy/source/common/network/connection_impl.cc:547] [C0] socket event: 2
[2022-02-08 16:24:22.343][9406][trace][connection] [external/envoy/source/common/network/connection_impl.cc:656] [C0] write ready

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

No branches or pull requests

1 participant