Fork me on GitHub
#babashka
<
2024-06-06
>
m3tti11:06:23

hey does anymody know why i get less data with babashka.http-client than pinging my endpoint with curl? Its about elastic if i do a _cat/indices in babashka i get less data but still valid than i get with curl

leifericf11:06:10

Just a guess: Could it be that one includes more data in the HTTP response header or something like that? Have you tried diffing the responses? I'm not sure what you mean by “less data.”

leifericf11:06:55

Also, I believe https://github.com/babashka/babashka.curl as well, so you could give that a go to see whether the response differs from curl outside of Babashka.

til 1
m3tti11:06:12

thats the strange thing

m3tti11:06:39

curl -XGET http://localhost:9200/_cat/indices?format=json this gives me 18 elements in the response array doing it with babashka same url gives me like 4

m3tti11:06:03

and i'm using babashka.http-client

leifericf11:06:59

Are the elements of the same expected data “type” in both cases, i.e., only the number of elements differ? By “less data” do you mean fewer elements or fewer bytes? :thinking_face:

leifericf11:06:16

What happens if you use curl without specifying -XGET?

m3tti11:06:32

samoe

👍 1
m3tti11:06:51

less elements i mean

👍 1
leifericf11:06:06

I presume your request headers and params are the same in both cases. Maybe inspect the requests to ensure they’re the same.

m3tti11:06:24

how could i do that 😄

m3tti11:06:25

with curl -kv it gives me

* TCP_NODELAY set
* Connected to localhost (::1) port 9200 (#0)
> GET /_cat/indices?format=json HTTP/1.1
> Host: localhost:9200
> User-Agent: curl/7.58.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< X-elastic-product: Elasticsearch
< Warning: 299 Elasticsearch-7.17.21-d38e4b028f4a9784bb74de339ac1b877e2dbea6f "Elasticsearch built-in security features are not enabled. Without authentication, your cluster could be accessible to anyone. See  to enable security."
< content-type: application/json; charset=UTF-8
< content-length: 4147
< 

👀 1
leifericf11:06:44

I'm on my phone on vacation in Japan without a laptop waiting for my son to fall asleep in a dark bedroom 😄 I can't help you with the details off the top of my head in this particular situation, hehe 😅

m3tti11:06:47

and that is what bb gives me as headers

{content-encoding gzip, content-length 422, content-type application/json; charset=UTF-8, warning 299 Elasticsearch-7.17.21-d38e4b028f4a9784bb74de339ac1b877e2dbea6f "Elasticsearch built-in security features are not enabled. Without authentication, your cluster could be accessible to anyone. See  to enable security.", x-elastic-product Elasticsearch}

👀 1
leifericf11:06:35

I'm afraid I can't be of more help with the technical details of how to diff HTTP requests/responses from my phone. Perhaps I can tag team @U3X7174KS in here if he has the time and facilities to go deeper on that ☺️

m3tti11:06:16

ok strange if i use curl via the process api i get the same result as with babashka.http-client. So what is now the diffrence the process is even started with the same user 😄

m3tti11:06:24

totally wired

borkdude11:06:16

maybe something to do with headers that are sent differently from curl and JVM?

3
m3tti11:06:50

but even if i directly call curl from the jvm i get less results than directly from bash

teodorlu11:06:38

I’m lead to believe that the HTTP request must be different, as Michiel suggests. I’d try narrowing down the difference between the JVM HTTP Client and the Curl command line client.

teodorlu12:06:43

With curl, you can use --verbose to list the request HTTP headers. When I run

curl --verbose -I 
, I get a part of the output that looks like this:
> HEAD / HTTP/2
> Host: 
> User-Agent: curl/8.6.0
> Accept: */*
, meaning the Host header is , etc. You can override headers with -H, like
curl --verbose -I -H 'User-Agent: teodors-agent' 

👍 1
m3tti12:06:08

OH MY GOD you don't want to know what the issue was -.-

grav12:06:00

you hit different servers?

m3tti12:06:19

i have switched the elastic into docker and somehow on the server someone started another native elastic which was installed on the server

😅 1
m3tti12:06:31

-.- and guess what curl from the cli reached out to the native one

m3tti12:06:38

while babashka got the docker one

😂 2
m3tti12:06:45

man i'm dying

m3tti13:06:19

crazy though BOTH elastic servers were able to attach to port 9200 😮 on localhost

🤯 2
grav13:06:09

Found [this](https://www.reddit.com/r/godot/comments/t33kxi/can_you_have_multiple_servers_on_one_port_or_do/#:~:text=this%20is%20possible%2C%20but%20it,they're%20on%20different%20interfaces.) on Google. Virtual network interfaces something-something - I guess it's a plausible explanation, since Docker creates those

borkdude13:06:20

ah, you won't be the first person to encounter this :)

m3tti13:06:16

anyway thanx guys for all that input. man i have to take a walk now.

clojure-spin 2
❤️ 2
☀️ 1
Stephan Renatus09:06:50

localhost is 127.0.0.1 and ::1 (ipv6). it’s possible that one service binds to the port on ipv4 and the other one on ipv6. terrible, but true.

borkdude09:06:48

yes, this came up before in this channel :)

Stephan Renatus09:06:13

sorry must have scrolled past that

borkdude09:06:00

I didn't mean that you should have seen this, just something I was reminded of from the past

😃 2
borkdude09:06:29

actually I can't find it myself, so my remark was totally meaningless ;)

borkdude09:06:46

I did find an issue with ports you posted 11 months ago, which was different

😄 1
😂 1
leifericf02:06:24

This thread is a great example of how everyone at all skill levels can learn something from asking and (trying to) answer questions. Now I know more than I did before and also a bit more about what I don't know much about.

💯 1
❤️ 1