R
Railway•12mo 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•12mo ago
Project ID: 32a99781-62bd-4751-b019-02237bc18552
sagat
sagatOP•12mo ago
32a99781-62bd-4751-b019-02237bc18552
Brody
Brody•12mo ago
the service that you are trying to connet to melisearch from, is it built with an dockerfile that uses alpine?
sagat
sagatOP•12mo ago
it is a golang service. I dont build a docker manually, it is automatically built by railway.
Brody
Brody•12mo ago
are you using railway's meilisearch template?
sagat
sagatOP•12mo ago
Correct!
Brody
Brody•12mo ago
show the meilisearch client go code please
sagat
sagatOP•12mo 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•12mo ago
does it print the variable?
sagat
sagatOP•12mo ago
will check again give me a sec
sagat
sagatOP•12mo ago
It does
No description
sagat
sagatOP•12mo ago
2nd line
Brody
Brody•12mo ago
at what point in your apps lifecycle does that function run?
sagat
sagatOP•12mo 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•12mo ago
the variable may print, but it that the correct domain according to the one listed in the meilisearch's settings
sagat
sagatOP•12mo ago
No description
Brody
Brody•12mo ago
have you tried with the public url?
sagat
sagatOP•12mo ago
will try again, did, but lets see
Brody
Brody•12mo ago
and side question, can you call meilisearch's public address directly? locally
sagat
sagatOP•12mo 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•12mo ago
same error when using the public url?
sagat
sagatOP•12mo ago
Correct Actually this has to be a connection issue within railway.
Brody
Brody•12mo ago
can you do some simple lookups in an init function?
sagat
sagatOP•12mo ago
like? u have example code? then I can push to develop Gore But I am owner so dont care.
Brody
Brody•12mo ago
not on hand, it's just standard library stuff though
sagat
sagatOP•12mo ago
what kind of lookup? like ping an address?
Brody
Brody•12mo ago
a DNS lookup on the meilisearch url
sagat
sagatOP•12mo 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•12mo ago
looks good to me, just dont assume the answer will be an A type, the internal domains will resolve to AAAA types
sagat
sagatOP•12mo 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•12mo 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
sagatOP•12mo ago
EXTRA string=fd12:64a2:cf2c:0:4000:1:eb1b:cc6a)meilisearch.railway.internal this is internal?
Brody
Brody•12mo ago
yep that's an ipv6 address
sagat
sagatOP•12mo ago
So this is correct?
Brody
Brody•12mo ago
so there's nothing wrong with the lookups, that makes it incredibly unlikely to be a railway issue
sagat
sagatOP•12mo 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•12mo ago
going forward, for good measure add a 3 second sleep to the beginning of your start command
sagat
sagatOP•12mo ago
you mean before the meili client is instantiated?
Brody
Brody•12mo ago
if you think you can work that out properly then yes, otherwise add the sleep to the start command itself
sagat
sagatOP•12mo 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•12mo 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
sagatOP•12mo 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•12mo ago
do you have a 3 second sleep in the start command?
sagat
sagatOP•12mo ago
how shall i add it? with the ui from railway?
Brody
Brody•12mo ago
change your start command to include a sleep 3
sagat
sagatOP•12mo ago
U mean here?
No description
Brody
Brody•12mo ago
yes
sagat
sagatOP•12mo ago
So?
No description
Brody
Brody•12mo ago
you need to join then with &&
sagat
sagatOP•12mo ago
sleep 3 && bin/api
Brody
Brody•12mo ago
yes
sagat
sagatOP•12mo 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•12mo ago
is railway using the new start command with a sleep in it? check the build table
sagat
sagatOP•12mo ago
No description
sagat
sagatOP•12mo ago
This is the calling code
No description
sagat
sagatOP•12mo ago
There is nothing special in it. It should work out of the fckn box
Brody
Brody•12mo 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
sagatOP•12mo 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•12mo 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
sagatOP•12mo ago
Does not make sense to me, it should error out on the other env too.
Brody
Brody•12mo ago
code issues aren't always going to make sense
sagat
sagatOP•12mo 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•12mo ago
not really
sagat
sagatOP•12mo 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•12mo 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
sagatOP•12mo 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•12mo ago
do you have any issues accessing the service itself?
sagat
sagatOP•12mo ago
My service, the golang one? No, this works just fine.
Brody
Brody•12mo ago
then there wouldn't be an issue with that line if you can access the service itself just fine
Want results from more Discord servers?
Add your server