# Backend-plugin resource handler strips out connection headers

**URL:** <https://community.grafana.com/t/backend-plugin-resource-handler-strips-out-connection-headers/111896>\
**Category:** Grafana Plugin Development\
**Tags:** api, plugins\
**Created:** [January 13, 2024, 3:29am UTC](https://community.grafana.com/t/backend-plugin-resource-handler-strips-out-connection-headers/111896 "2024-01-13T03:29:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vaduga](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/vaduga/32/57313_2.png) [@vaduga](https://community.grafana.com/u/vaduga)\
**Post date:** [January 13, 2024, 3:29am UTC](https://community.grafana.com/t/backend-plugin-resource-handler-strips-out-connection-headers/111896/1 "2024-01-13T03:29:03Z")

</div>

Following this showcase [How to add a resource handler for your data source - #3 by mefraimsson](https://community.grafana.com/t/how-to-add-a-resource-handler-for-your-data-source/58924/3) and App with backend plugin example [grafana-plugin-examples/examples/app-with-backend at main · grafana/grafana-plugin-examples · GitHub](https://github.com/grafana/grafana-plugin-examples/tree/main/examples/app-with-backend)  
I encountered a problem with CallResource function receiving request object with stripped out Connection: ‘upgrade’ headers. And if I add these headers manually in the handler function it throws error that theres no http.hijacker.

I want to run my own simple webrtc signaling websocket server at one of the resource handlers urls, for example at /api/plugins/my-app/resources/ws .  
I do succeed running separate goroutine with http.ListenAndServe at custom port with my websocket handler, but I guess it would better to use api resource handler for my app plugin.

Could someone please point me to a Grafana sourcecode where and why it strips connection headers for resource handlers and advice if it is technically possible to open custom websocket connections (other than grafana live) for my app plugin resource handlers?

---

<div class="post-metadata">

**Author:** ![anon34853223](https://avatars.discourse-cdn.com/v4/letter/a/71c47a/32.png) [@anon34853223](https://community.grafana.com/u/anon34853223)\
**Post date:** [January 17, 2024, 1:27pm UTC](https://community.grafana.com/t/backend-plugin-resource-handler-strips-out-connection-headers/111896/2 "2024-01-17T13:27:53Z")

</div>

I’m not sure you can use call resource to proxy a websocket connection/not supported due to not supported here [grafana/pkg/plugins/manager/client/client.go at a103be2285710f8c1c2dac470595336f816da9ff · grafana/grafana · GitHub](https://github.com/grafana/grafana/blob/a103be2285710f8c1c2dac470595336f816da9ff/pkg/plugins/manager/client/client.go#L95). Not sure we want to support it either given that there are multiple alternatives.

What you can do if you don’t want to use Grafana live streaming, is to use the datasource proxy. Then you’ll need to convert proxy url to ws:// scheme, examples

> <https://github.com/grafana/grafana/blob/a103be2285710f8c1c2dac470595336f816da9ff/public/app/plugins/datasource/loki/datasource.ts#L400>

> <https://github.com/grafana/grafana/blob/a103be2285710f8c1c2dac470595336f816da9ff/public/app/plugins/datasource/loki/streaming.ts#L90>

Then you can use that url to connect to websocket over Grafana’s datasource proxy.

We’re planning to improve documentation around this [Docs: Document how to connect over websocket thru datasource proxy · Issue #46798 · grafana/grafana · GitHub](https://github.com/grafana/grafana/issues/46798)

---

<div class="post-metadata">

**Author:** ![vaduga](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/vaduga/32/57313_2.png) [@vaduga](https://community.grafana.com/u/vaduga)\
**Post date:** [January 17, 2024, 1:41pm UTC](https://community.grafana.com/t/backend-plugin-resource-handler-strips-out-connection-headers/111896/3 "2024-01-17T13:41:29Z")

</div>

Thanks a lot! Was hoping for your response on that

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/grafana/original/2X/e/ef5308cc58c9e5a13187b5012eb99f406928462f.png) [@system](https://community.grafana.com/u/system)\
**Post date:** [January 16, 2025, 1:42pm UTC](https://community.grafana.com/t/backend-plugin-resource-handler-strips-out-connection-headers/111896/4 "2025-01-16T13:42:23Z")

</div>

Closed on January 16, 2025, 1:42pm UTC

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
