Dear Community User! We have started the migration process.
This community is now in READ ONLY mode.
Read more: Important information on the platform change.

cancel
Showing results for 
Search instead for 
Did you mean: 
SOLVED

Can't seem to reach my custom web server

Can't seem to reach my custom web server

tom-roozen
Member

Hey all,

I am trying to develop an integration for the ctrlX CORE by building a webserver that serves a HTML page. I have followed the guide on reverse-proxy and I am using a unix socket.

I have also looked at both the Go and Python webserver example, and tried to compare as much as I could. I've uploaded the Go sample and it simply worked. I'm guessing its a small issue somewhere in the configuration, as I don't see any traffic coming to my webserver.

I am able to connect to my webserver via nc:

echo -e "GET /register-my-snap/ HTTP/1.1\r\nHost: localhost\r\n\r\n" | sudo nc -q2 -U /var/snap/my-snap-name/current/package-run/my-snap-name/web.sock

<!DOCTYPE html>
...
</html>

However when I try to access the link I've set up in my package-manifest.json I receive a "The app is currently not available" page. Is it possible to somewhere enable Caddy logging output? I've tried editing various files but did not find a solution. I can't see any reasonable information in the logbook/journalctl about why it could be failing.

my-snap-name.package-manifest.json:

{
"$schema": "https://json-schema.boschrexroth.com/ctrlx-automation/ctrlx-core/apps/package-manifest/package-manifest.v1.3.schema.json",
"version": "1.0.0",
"id": "my-snap-name",
"configuration": {
"appDirectories": [
{
"name": "my-snap",
"description": "my-snap",
"copyOnLoad": true
}
]
},
"services": {
"proxyMapping": [
{
"name": "my-snap-name.web",
"url": "/register-my-snap/",
"binding": "unix://{$SNAP_DATA}/package-run/my-snap-name/web.sock",
"restricted": []
}
]
},
"menus": {
"sidebar": [
{
"id": "my-snap-name",
"title": "My Snap",
"items": [
{
"id": "register",
"title": "Register My Snap",
"target": "_blank",
"link": "/register-my-snap/"
}
]
}
]
}
}

 

snapcraft.yaml:

name: my-snap-name
base: core20
version: '1.0.0'

grade: stable
confinement: strict

architectures:
- build-on: amd64
run-on: arm64

apps:
my-snap-name:
command: usr/bin/run.sh
daemon: simple
restart-condition: always
restart-delay: 5s
plugs:
- active-solution
- hardware-observe
- network
- network-bind
- network-control

plugs:
active-solution:
interface: content
content: solutions
target: $SNAP_COMMON/solutions

hooks:
connect-plug-active-solution:
plugs: [active-solution]

slots:
package-assets:
interface: content
content: package-assets
source:
read:
- $SNAP/package-assets/${SNAPCRAFT_PROJECT_NAME}
package-run:
interface: content
content: package-run
source:
write:
- $SNAP_DATA/package-run/${SNAPCRAFT_PROJECT_NAME}

parts:
my-snap:
source: bin/my-snap.deb
plugin: dump
webserver:
source: ./www
plugin: dump
organize:
'*' : www/
configs:
source: snap/local/configs
plugin: dump
organize:
'package-assets/*': package-assets/${SNAPCRAFT_PROJECT_NAME}/

 

Thank you all in advance!

1 REPLY 1

tom-roozen
Member

It seems this has fixed itself, I think it may have been the app name not being identical to the snap name. Or potentially something wasn't correctly configured with the unix socket binding.

Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist