gotify / server

A simple server for sending and receiving messages in real-time per WebSocket. (Includes a sleek web-ui)
https://gotify.net
Other
11k stars 619 forks source link

How to connect to a MySQL db? #283

Closed YouveGotMeowxy closed 4 years ago

YouveGotMeowxy commented 4 years ago

Have you read the documentation?

You are setting up gotify in

Describe your problem

I am trying to start a new instance of gotify using mysql instead of sqlite, and can't get it to connect to the MySQL server that runs in another container, placed in the same docker network as this gotify container, and with the hostname 'mysql'.

Normally in docker you can just place 2 containers in the same docker network, and use the container's name, or it's hostname, and docker will do all the resolving for you; you just call 'mysql' in any other container's db settings. I can't seem to figure out how to do this with gotify's config?

I have tried:

- GOTIFY_DATABASE_DIALECT=mysql
- GOTIFY_DATABASE_CONNECTION='gotify:mypw@mysql:3306/gotifydb?charset=utf8&parseTime=True&loc=Local'

But I just get errors in the gotify log like:

Starting Gotify version 2.0.14@2020-02-18-18:48:32

panic: default addr for network 'mysql:3306' unknown

goroutine 1 [running]:

main.main()

/proj/app.go:47 +0x4ed

Using this instead:

- GOTIFY_DATABASE_CONNECTION='gotify:mypw@tcp(mysql):3306/gotifydb?charset=utf8&parseTime=True&loc=Local'

Gives this error:

Starting Gotify version 2.0.14@2020-02-18-18:48:32

panic: invalid DSN: did you forget to escape a param value?

goroutine 1 [running]:

main.main() /proj/app.go:47 +0x4ed

And so on ....

Any errors, logs, or other information that might help us identify your problem

Ex: docker-compose.yml, nginx.conf, android logcat, browser requests, etc.

Name of the information here

contents here

jmattheis commented 4 years ago

You need to use root:password@tcp(mysql:3306)/gotify?charset=utf8&parseTime=True&loc=Local (port inside tcp()) Ensure, that mysql is ready before starting gotify.

version: '2'

services:
    gotify:
        container_name: gotify
        hostname: gotify
        image: gotify/server:latest
        environment:
            - GOTIFY_DATABASE_DIALECT=mysql
            - GOTIFY_DATABASE_CONNECTION=root:password@tcp(mysql:3306)/gotify?charset=utf8&parseTime=True&loc=Local
        restart: unless-stopped
        volumes:
            - "./data:/app/data"
    mysql:
        image: mariadb:10.1.15
        ports:
            - 1337:3306
        environment:
            MYSQL_ROOT_PASSWORD: "password"
            MYSQL_USER: "root"
            MYSQL_DATABASE: "gotify"
            MYSQL_ROOT_HOST: "%"
YouveGotMeowxy commented 4 years ago

Got it! TY!

YouveGotMeowxy commented 4 years ago

@jmattheis 1 more quick question! (sorry!)

Why doesn't this recognize the correct token?

image

image

jmattheis commented 4 years ago

You need a client token to access messages. Application Tokens are only allowed to send messages.

YouveGotMeowxy commented 4 years ago

@jmattheis If I send that url, shouldn't the message still show up in the gotify webui? Nothing shows up there even though I copy/pasted that token?

jmattheis commented 4 years ago

how do you post the url, are there any error messages?

YouveGotMeowxy commented 4 years ago

@jmattheis Well, I'm trying to get Tautulli to send gotify notifications using it's Webhook, that I can't get working, so In the process of testing, (this example) I just pasted that exact URL in the screenshot into Chrome and hit enter to send it, and that's where I'm at. I was thinking that it would at least send the notification to Gotify, but it doesn't.

This is all that shows up in the console:

image

I'm not sure if you're familiar with Tautulli, but this is the Webhook interface to fill out the info (it sends via json), does this look correct? (It doesn't send anything like this):

image

jmattheis commented 4 years ago

If you paste the url in your browser, you make a http GET-request. Adding a message must be done via post. Have you looked into your tautulli/gotify logs? Have you changed the json in the data tab to match the message format of gotify? https://gotify.net/api-docs#/message/createMessage