R
Railway•6mo ago
sagat

Meilisearch not reachable

We use meilisearch in different envs, but it only works in our local env, not in development for example. I tried everythin already. I moved it to another zone, I tried private and public urls. I also tried to connect from my dev to local env, didn't work either. I experienced lately that when I launch a service and it automatically starts in all envs, it is only available in the env where I started it. I could delete the whole service, but apparently it says that it is going to delete every service instance of it in any env. The Error:
{
"headers": {
"normalizedNames": {},
"lazyUpdate": null
},
"status": 500,
"statusText": "OK",
"url": "https://api.dev.feature-vote.cheveo.de/boards/search",
"ok": false,
"name": "HttpErrorResponse",
"message": "Http failure response for https://api.dev.feature-vote.cheveo.de/boards/search: 500 OK",
"error": {
"message": "MeilisearchCommunicationError unable to execute request (path \"POST /indexes/boards/search\" with method \"Search\"): lookup : no such host"
}
}
{
"headers": {
"normalizedNames": {},
"lazyUpdate": null
},
"status": 500,
"statusText": "OK",
"url": "https://api.dev.feature-vote.cheveo.de/boards/search",
"ok": false,
"name": "HttpErrorResponse",
"message": "Http failure response for https://api.dev.feature-vote.cheveo.de/boards/search: 500 OK",
"error": {
"message": "MeilisearchCommunicationError unable to execute request (path \"POST /indexes/boards/search\" with method \"Search\"): lookup : no such host"
}
}
Please help, my app is supposed to go to alpha testround today 🙂
69 Replies
Percy
Percy•6mo ago
Project ID: 32a99781-62bd-4751-b019-02237bc18552
sagat
sagat•6mo ago
32a99781-62bd-4751-b019-02237bc18552
Brody
Brody•6mo ago
the service that you are trying to connet to melisearch from, is it built with an dockerfile that uses alpine?
sagat
sagat•6mo ago
it is a golang service. I dont build a docker manually, it is automatically built by railway.
Brody
Brody•6mo ago
are you using railway's meilisearch template?
sagat
sagat•6mo ago
Correct!
Brody
Brody•6mo ago
show the meilisearch client go code please
sagat
sagat•6mo ago
You mean how I connect from go? Will do, but it works on my other environment thats why I would not think it is an implementation problem
func GetSearchClient() *meilisearch.Client {
fmt.Println(os.Getenv("MEILISEARCH_URL"))

client := meilisearch.NewClient(meilisearch.ClientConfig{
Host: os.Getenv("MEILISEARCH_URL"),
APIKey: os.Getenv("MEILISEARCH_MASTER_KEY"),
})

return client
}
func GetSearchClient() *meilisearch.Client {
fmt.Println(os.Getenv("MEILISEARCH_URL"))

client := meilisearch.NewClient(meilisearch.ClientConfig{
Host: os.Getenv("MEILISEARCH_URL"),
APIKey: os.Getenv("MEILISEARCH_MASTER_KEY"),
})

return client
}
this is how i get the searchclient
Brody
Brody•6mo ago
does it print the variable?
sagat
sagat•6mo ago
will check again give me a sec
sagat
sagat•6mo ago
It does
No description
sagat
sagat•6mo ago
2nd line
Brody
Brody•6mo ago
at what point in your apps lifecycle does that function run?
sagat
sagat•6mo ago
Everytime I make a call to meilisearch. As I said, it is working on the other environment completely, thats why I dont think that this is a code issue
Brody
Brody•6mo ago
the variable may print, but it that the correct domain according to the one listed in the meilisearch's settings
sagat
sagat•6mo ago
No description
Brody
Brody•6mo ago
have you tried with the public url?
sagat
sagat•6mo ago
will try again, did, but lets see
Brody
Brody•6mo ago
and side question, can you call meilisearch's public address directly? locally
sagat
sagat•6mo ago
same error. I can get onto the ui, since it is in development mode. so, I can see it when I use the public url.
Brody
Brody•6mo ago
same error when using the public url?
sagat
sagat•6mo ago
Correct Actually this has to be a connection issue within railway.
Brody
Brody•6mo ago
can you do some simple lookups in an init function?
sagat
sagat•6mo ago
like? u have example code? then I can push to develop Gore But I am owner so dont care.
Brody
Brody•6mo ago
not on hand, it's just standard library stuff though
sagat
sagat•6mo ago
what kind of lookup? like ping an address?
Brody
Brody•6mo ago
a DNS lookup on the meilisearch url
sagat
sagat•6mo ago
will do like this:
ips, err := net.LookupIP("google.com")
if err != nil {
fmt.Fprintf(os.Stderr, "Could not get IPs: %v\n", err)
os.Exit(1)
}
for _, ip := range ips {
fmt.Printf("google.com. IN A %s\n", ip.String())
}
ips, err := net.LookupIP("google.com")
if err != nil {
fmt.Fprintf(os.Stderr, "Could not get IPs: %v\n", err)
os.Exit(1)
}
for _, ip := range ips {
fmt.Printf("google.com. IN A %s\n", ip.String())
}
for public and private url
Brody
Brody•6mo ago
looks good to me, just dont assume the answer will be an A type, the internal domains will resolve to AAAA types
sagat
sagat•6mo ago
it is building back in 5 Gives me this (EXTRA string=34.32.135.56)meilisearch-development-xxxx.up.railway.app xxxx is placeholder
Brody
Brody•6mo ago
okay that is the public ip, looks good to me. what about the private when doing a lookup on the private domain make sure you add a 3 second sleep before the lookup
sagat
sagat•6mo ago
EXTRA string=fd12:64a2:cf2c:0:4000:1:eb1b:cc6a)meilisearch.railway.internal this is internal?
Brody
Brody•6mo ago
yep that's an ipv6 address
sagat
sagat•6mo ago
So this is correct?
Brody
Brody•6mo ago
so there's nothing wrong with the lookups, that makes it incredibly unlikely to be a railway issue
sagat
sagat•6mo ago
that is really really strange. What I will do now is, I will delete the service completely from withtin dev env, then recreate a new service from within dev and lets see if it then works, that would be really interesting. cause i noticed the same issue with postgres before. I always had to delete the service in each env where it was created automatically and manually create a new one, after that everything worked as expected. Let me check.
Brody
Brody•6mo ago
going forward, for good measure add a 3 second sleep to the beginning of your start command
sagat
sagat•6mo ago
you mean before the meili client is instantiated?
Brody
Brody•6mo ago
if you think you can work that out properly then yes, otherwise add the sleep to the start command itself
sagat
sagat•6mo ago
well since the meiliclient will only be instantiated when i make an api call to a search endpoint, I can manually control the time before i execute this.
Brody
Brody•6mo ago
you only need a single 3 second sleep to delay the starting of the entire app, that's why I'm recommending adding the sleep to the start command
sagat
sagat•6mo ago
meilisearch-ecac9e46.railway.internal%!(EXTRA string=fd12:64a2:cf2c::45:78df:1994)meilisearch-ecac9e46.railway.internal

MeilisearchCommunicationError unable to execute request (path "POST /indexes/boards/documents?primaryKey=id" with method "AddDocuments"): lookup : no such host

[GIN] 2023/12/18 - 09:35:56 | 500 | 152.773251ms | 88.130.144.22 | POST "/boards"

Error #01: MeilisearchCommunicationError unable to execute request (path "POST /indexes/boards/documents?primaryKey=id" with method "AddDocuments"): lookup : no such host
meilisearch-ecac9e46.railway.internal%!(EXTRA string=fd12:64a2:cf2c::45:78df:1994)meilisearch-ecac9e46.railway.internal

MeilisearchCommunicationError unable to execute request (path "POST /indexes/boards/documents?primaryKey=id" with method "AddDocuments"): lookup : no such host

[GIN] 2023/12/18 - 09:35:56 | 500 | 152.773251ms | 88.130.144.22 | POST "/boards"

Error #01: MeilisearchCommunicationError unable to execute request (path "POST /indexes/boards/documents?primaryKey=id" with method "AddDocuments"): lookup : no such host
Same Error.
Brody
Brody•6mo ago
do you have a 3 second sleep in the start command?
sagat
sagat•6mo ago
how shall i add it? with the ui from railway?
Brody
Brody•6mo ago
change your start command to include a sleep 3
sagat
sagat•6mo ago
U mean here?
No description
Brody
Brody•6mo ago
yes
sagat
sagat•6mo ago
So?
No description
Brody
Brody•6mo ago
you need to join then with &&
sagat
sagat•6mo ago
sleep 3 && bin/api
Brody
Brody•6mo ago
yes
sagat
sagat•6mo ago
LOL Ur sentence confused me hard 😄
meilisearch-ecac9e46.railway.internal%!(EXTRA string=fd12:64a2:cf2c::45:78df:1994)meilisearch-ecac9e46.railway.internal

&{ 0 25 1 25}

[GIN] 2023/12/18 - 09:42:36 | 500 | 139.013534ms | 88.130.144.22 | POST "/boards/search"

Error #01: MeilisearchCommunicationError unable to execute request (path "POST /indexes/boards/search" with method "Search"): lookup : no such host
meilisearch-ecac9e46.railway.internal%!(EXTRA string=fd12:64a2:cf2c::45:78df:1994)meilisearch-ecac9e46.railway.internal

&{ 0 25 1 25}

[GIN] 2023/12/18 - 09:42:36 | 500 | 139.013534ms | 88.130.144.22 | POST "/boards/search"

Error #01: MeilisearchCommunicationError unable to execute request (path "POST /indexes/boards/search" with method "Search"): lookup : no such host
Same FML
Brody
Brody•6mo ago
is railway using the new start command with a sleep in it? check the build table
sagat
sagat•6mo ago
No description
sagat
sagat•6mo ago
This is the calling code
No description
sagat
sagat•6mo ago
There is nothing special in it. It should work out of the fckn box
Brody
Brody•6mo ago
your error lookup : no such host is incomplete, it should at least read something like this https://utilities.up.railway.app/dns-lookup?value=non-existent.railway.internal&type=ip your error is missing the host and dns resolver, mine isnt so somewhere in your code or some package you are using, something is going wrong
sagat
sagat•6mo ago
Will print the error in place now with err.Error() to be sure that the info is maybe lost on the propagation part. Okay I have a question then, why does it work in other environments?
Brody
Brody•6mo ago
no clue but you have proven that you can indeed successfully lookup both the public and private domains, if this was an issue with railway those lookups would have failed
sagat
sagat•6mo ago
Does not make sense to me, it should error out on the other env too.
Brody
Brody•6mo ago
code issues aren't always going to make sense
sagat
sagat•6mo ago
true, but still it does bother me, there is one difference from the local to dev env. will test this. U cant be serius fml on the local env in railway i have prefixed the public url with https, this works then also for the dev env does that make any sense to u?
Brody
Brody•6mo ago
not really
sagat
sagat•6mo ago
😄 but actually I want to use the internal url for better performance or doesnt the public url go first out of the network and then back in? and It will up the costs I think as well
Brody
Brody•6mo ago
using the public url would have more hops, yes, and you would be subjecting yourself to egress fees. you do want to use the private url, and for clarity sake when using an internal domain your scheme would be http and not https
sagat
sagat•6mo ago
redeploying and checking Could one issue be, that my service starts here:
r.Run(fmt.Sprintf("0.0.0.0:%s", os.Getenv("PORT")))
r.Run(fmt.Sprintf("0.0.0.0:%s", os.Getenv("PORT")))
Port is 3001
Brody
Brody•6mo ago
do you have any issues accessing the service itself?
sagat
sagat•6mo ago
My service, the golang one? No, this works just fine.
Brody
Brody•6mo ago
then there wouldn't be an issue with that line if you can access the service itself just fine