question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Continuous recording: panic: runtime error: invalid memory address or nil pointer dereference

See original GitHub issue

Hello,

I am trying enable “Continuous recording” but no success. Every time I enable container crash. I am using docker +docker compose instead of kubernetes.

docker-compose.yml

version: '3'

services:
  kerberos-agent:
    image: 'kerberos/agent-dev:arch-amd64-a67c84a'
    restart: always
    container_name: 'kerberos-camera1'
    hostname: 'kerberos-camera1'
    ports:
      - '8080'
    volumes:
      - "./agent/config:/home/agent/data/config"
      - "./agent/recordings:/home/agent/data/recordings"

    labels:
      - 'traefik.enable=true'
      - 'traefik.http.routers.kerberos-camera1.rule=Host(`kerberos-camera1.domain.tld`)'
      - 'traefik.http.routers.kerberos-camera1.entrypoints=websecure'
      - 'traefik.http.routers.kerberos-camera1.tls=true'
      - 'traefik.http.routers.kerberos-camera1.tls.certresolver=leresolver'
      - 'traefik.http.services.kerberos-camera1.loadbalancer.server.port=8080'

  kerberos-vault:
    image: 'kerberos/vault:latest'
    restart: always
    container_name: 'kerberos-vault'
    hostname: 'kerberos-vault'
    ports:
      - '80'
      - '8081'
    volumes:
      - "./vault:/vault"
    environment:
      - GIN_MODE=release
      - STORAGE_API_URL=kerberos-vault-api.domain.tld
      - KERBEROS_LOGIN_USERNAME=root
      - KERBEROS_LOGIN_PASSWORD=pass
      - MONGODB_HOST=kerberos-mongo
      - MONGODB_DATABASE_CREDENTIALS=admin
      - MONGODB_USERNAME=root
      - MONGODB_PASSWORD=pass
      - MONGODB_DATABASE_STORAGE=KerberosStorage
    labels:
      - 'traefik.enable=true'
      - 'traefik.http.routers.kerberos-vault.rule=Host(`kerberos-vault.domain.tld`)'
      - 'traefik.http.routers.kerberos-vault.entrypoints=websecure'
      - 'traefik.http.routers.kerberos-vault.tls=true'
      - 'traefik.http.routers.kerberos-vault.tls.certresolver=leresolver'
      - "traefik.http.routers.kerberos-vault.service=kerberos_vault"
      - 'traefik.http.services.kerberos_vault.loadbalancer.server.port=80'
      - 'traefik.http.routers.kerberos-vault-api.rule=Host(`kerberos-vault-api.domain.tld`)'
      - 'traefik.http.routers.kerberos-vault-api.entrypoints=websecure'
      - 'traefik.http.routers.kerberos-vault-api.tls=true'
      - 'traefik.http.routers.kerberos-vault-api.tls.certresolver=leresolver'
      - "traefik.http.routers.kerberos-vault-api.service=kerberos_vault_api"
      - 'traefik.http.services.kerberos_vault_api.loadbalancer.server.port=8081'

  kerberos-mongo:
    image: 'mongo:4.4.16'
    container_name: 'kerberos-mongo'
    hostname: 'kerberos-mongo'
    ports:
      - 27017
    volumes:
      - ./mongodb:/data/db
    environment:
      - MONGO_INITDB_ROOT_USERNAME=root
      - MONGO_INITDB_ROOT_PASSWORD=pass

volumes:
  kerberos-data:

networks:
  default:
      name: cluster-net
      external: true

Docker Logs:

[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.

[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:   export GIN_MODE=release
 - using code:  gin.SetMode(gin.ReleaseMode)

[GIN-debug] GET    /debug/pprof/             --> github.com/gin-gonic/gin.WrapF.func1 (3 handlers)
[GIN-debug] GET    /debug/pprof/cmdline      --> github.com/gin-gonic/gin.WrapF.func1 (3 handlers)
[GIN-debug] GET    /debug/pprof/profile      --> github.com/gin-gonic/gin.WrapF.func1 (3 handlers)
[GIN-debug] POST   /debug/pprof/symbol       --> github.com/gin-gonic/gin.WrapF.func1 (3 handlers)
[GIN-debug] GET    /debug/pprof/symbol       --> github.com/gin-gonic/gin.WrapF.func1 (3 handlers)
[GIN-debug] GET    /debug/pprof/trace        --> github.com/gin-gonic/gin.WrapF.func1 (3 handlers)
[GIN-debug] GET    /debug/pprof/allocs       --> github.com/gin-gonic/gin.WrapH.func1 (3 handlers)
[GIN-debug] GET    /debug/pprof/block        --> github.com/gin-gonic/gin.WrapH.func1 (3 handlers)
[GIN-debug] GET    /debug/pprof/goroutine    --> github.com/gin-gonic/gin.WrapH.func1 (3 handlers)
[GIN-debug] GET    /debug/pprof/heap         --> github.com/gin-gonic/gin.WrapH.func1 (3 handlers)
[GIN-debug] GET    /debug/pprof/mutex        --> github.com/gin-gonic/gin.WrapH.func1 (3 handlers)
[GIN-debug] GET    /debug/pprof/threadcreate --> github.com/gin-gonic/gin.WrapH.func1 (3 handlers)
{"level":"info","msg":"RunAgent: opening RTSP stream","time":"2022-09-08T16:10:58+01:00"}
[GIN-debug] GET    /swagger/*any             --> github.com/swaggo/gin-swagger.CustomWrapHandler.func1 (4 handlers)
[GIN-debug] GET    /config                   --> github.com/kerberos-io/agent/machinery/src/routers/http.AddRoutes.func1 (4 handlers)
[GIN-debug] POST   /config                   --> github.com/kerberos-io/agent/machinery/src/routers/http.AddRoutes.func2 (4 handlers)
[GIN-debug] POST   /api/login                --> github.com/appleboy/gin-jwt/v2.(*GinJWTMiddleware).LoginHandler-fm (4 handlers)
[GIN-debug] GET    /api/dashboard            --> github.com/kerberos-io/agent/machinery/src/routers/http.AddRoutes.func3 (4 handlers)
[GIN-debug] POST   /api/latest-events        --> github.com/kerberos-io/agent/machinery/src/routers/http.AddRoutes.func4 (4 handlers)
[GIN-debug] GET    /api/days                 --> github.com/kerberos-io/agent/machinery/src/routers/http.AddRoutes.func5 (4 handlers)
[GIN-debug] GET    /api/stream               --> github.com/kerberos-io/agent/machinery/src/routers/http.AddRoutes.func6 (4 handlers)
[GIN-debug] GET    /api/config               --> github.com/kerberos-io/agent/machinery/src/routers/http.AddRoutes.func7 (4 handlers)
[GIN-debug] POST   /api/config               --> github.com/kerberos-io/agent/machinery/src/routers/http.AddRoutes.func8 (4 handlers)
[GIN-debug] GET    /api/restart              --> github.com/kerberos-io/agent/machinery/src/routers/http.AddRoutes.func9 (4 handlers)
[GIN-debug] GET    /api/stop                 --> github.com/kerberos-io/agent/machinery/src/routers/http.AddRoutes.func10 (4 handlers)
[GIN-debug] POST   /api/hub/verify           --> github.com/kerberos-io/agent/machinery/src/routers/http.AddRoutes.func11 (4 handlers)
[GIN-debug] POST   /api/persistence/verify   --> github.com/kerberos-io/agent/machinery/src/routers/http.AddRoutes.func12 (4 handlers)
[GIN-debug] GET    /file/*filepath           --> github.com/gin-gonic/gin.(*RouterGroup).createStaticHandler.func1 (9 handlers)
[GIN-debug] HEAD   /file/*filepath           --> github.com/gin-gonic/gin.(*RouterGroup).createStaticHandler.func1 (9 handlers)
[GIN-debug] [WARNING] You trusted all proxies, this is NOT safe. We recommend you to set a value.
Please check https://pkg.go.dev/github.com/gin-gonic/gin#readme-don-t-trust-all-proxies for details.
[GIN-debug] Listening and serving HTTP on :8080
{"level":"info","msg":"ControlAgent: Number of packets read 0","time":"2022-09-08T16:10:58+01:00"}
{"level":"info","msg":"ConfigureMQTT: Set broker uri ","time":"2022-09-08T16:10:59+01:00"}
{"level":"info","msg":"ConfigureMQTT: Set username xxx","time":"2022-09-08T16:10:59+01:00"}
{"level":"info","msg":"ConfigureMQTT: Set password xxx","time":"2022-09-08T16:10:59+01:00"}
{"level":"error","msg":"HandleHeartBeat: (400) Something went wrong while sending to Kerberos Hub.","time":"2022-09-08T16:11:02+01:00"}
{"level":"info","msg":"HandleLiveStreamHD: Waiting for peer connections.","time":"2022-09-08T16:11:02+01:00"}
{"level":"info","msg":"HandleRecordStream: Start continuous recording ","time":"2022-09-08T16:11:02+01:00"}
{"level":"info","msg":"WriteToTrack: listing codecs.","time":"2022-09-08T16:11:02+01:00"}
{"level":"info","msg":"WriteToTrack: codec - H264 found.","time":"2022-09-08T16:11:02+01:00"}
{"level":"info","msg":"H264","time":"2022-09-08T16:11:02+01:00"}
{"level":"info","msg":"WriteToTrack: codec - PCM_ALAW found.","time":"2022-09-08T16:11:02+01:00"}
{"level":"info","msg":"PCM_ALAW","time":"2022-09-08T16:11:02+01:00"}
{"level":"info","msg":"WriteToTrack: not using a transcoder.","time":"2022-09-08T16:11:02+01:00"}
{"level":"info","msg":"ProcessMotion: Continuous recording, so no motion detection.","time":"2022-09-08T16:11:02+01:00"}
{"level":"info","msg":"HandleStream: packet size 176627","time":"2022-09-08T16:11:02+01:00"}
{"level":"info","msg":"Recording started","time":"2022-09-08T16:11:02+01:00"}
{"level":"info","msg":"HandleRecordStream: composing recording","time":"2022-09-08T16:11:02+01:00"}
{"level":"info","msg":"HandleRecordStream: write header","time":"2022-09-08T16:11:02+01:00"}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x6196a0]

goroutine 30 [running]:
github.com/kerberos-io/joy4/format/mp4.(*Muxer).WriteHeader(0xc000034050?, {0xc00046eaa0?, 0x242?, 0xc00041eec0?})
        /go/pkg/mod/github.com/kerberos-io/joy4@v1.0.33/format/mp4/muxer.go:154 +0x20
github.com/kerberos-io/agent/machinery/src/capture.HandleRecordStream(0xc00003c620?, 0xc0001e6000, 0xc0005d6070, {0xc00046eaa0, 0x2, 0x2})
        /go/src/github.com/kerberos-io/agent/machinery/src/capture/main.go:194 +0x18fb
created by github.com/kerberos-io/agent/machinery/src/components.RunAgent
        /go/src/github.com/kerberos-io/agent/machinery/src/components/Kerberos.go:125 +0x8ef

Please, can you help figure out?

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:14 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
nurio-felixcommented, Sep 12, 2022

did that help? @nurio-felix

@cedricve Sorry for delay. Yes, I created persistent volume and now is working fine. Thanks for help guys.

If you want pick docker-compose.yml stuff that I placed here for people that do not want deploy using kubernettes, you can add also to documentation.

docker-compose.yml

version: '3'

services:
  kerberos-agent:
    image: 'kerberos/agent-dev:latest'
    restart: always
    container_name: 'kerberos-agent'
    hostname: 'kerberos-agent'
    ports:
      - '8080'
    volumes:
      - "kerberos-data:/home/agent/data/config"
      - "kerberos-data:/home/agent/data/recordings"

    labels:
      - 'traefik.enable=true'
      - 'traefik.http.routers.kerberos-agent.rule=Host(`kerberos-agent.domain.tld`)'
      - 'traefik.http.routers.kerberos-agent.entrypoints=websecure'
      - 'traefik.http.routers.kerberos-agent.tls=true'
      - 'traefik.http.routers.kerberos-agent.tls.certresolver=leresolver'
      - 'traefik.http.services.kerberos-agent.loadbalancer.server.port=8080'

volumes:
  kerberos-data:

networks:
  default:
      name: cluster-net
      external: true
1reaction
nurio-felixcommented, Sep 13, 2022

wonderful! we have been looking into your approach, and actually like how you like to avoid kubernetes. Would you consider to write an medium/blog article to discuss your deployment? Might be really interesting for users, to quickly bootup some agents + a Kerberos Vault.

Yes I can write docker + docker compose implementation. I avoid kubernetes because actually I am using this for small scale in my home surveillance, so I think is more easy to setup.

For standart I think in their homes people will choose docker compose. It is possible making kerberos (agent + vault + storage) home surveillance using Port forwarding (80,443) in Router to Virtual Machine that can be created using Virtual Box with or without vaild domain name.

With kerberos is possible avoid NAS hardware, replaced by Minio, so I think is better in costs, one Virtual Machine with 2 Cores and 4GB RAM can make all work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Go: panic: runtime error: invalid memory address or nil pointer ...
"An error is returned if caused by client policy (such as CheckRedirect) ... The nil pointer dereference is in line 65 which is...
Read more >
panic: runtime error: invalid memory address or nil pointer ...
Hi there, I have a topology consisting of 48 docker containers. Each container runs its own geth node. (The docker containers are build...
Read more >
Invalid memory address or nil pointer dereference - YourBasic
CODE EXAMPLE An uninitialized pointer is nil, and you can't follow the nil pointer. If x is nil, an attempt to evaluate *x...
Read more >
Golang: panic: runtime error: invalid memory address or nil ...
To avoid this error, just new the variable, and it will be grant a memory address.
Read more >
GoLang APM agent panic runtime error: invalid memory ...
GoLang APM agent panic runtime error: invalid memory address or nil pointer dereference ... @marv72 sorry you're experiencing this, and thanks for ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found