saltcorn
saltcorn copied to clipboard
Real-Time Chat Room Example
Does anyone have a working example of a Real-Time Chat Room that they could share?
I tried to follow the WiKi but I'm stuck at an error "insert or update on table "Participants" violates foreign key constraint "Participants_room_id_fkey"".
Thanks.
I can help with that. Give me a day or so
@christianhugoch Thank you!
In our unit tests, we're using this model for the chat:
With that, you can create a room view with this configuration:
Message show view is used to show each message, so you can use a single textfield for the content.
New message form view is an edit view. You'll see it at the bottom, under the messages.
To create a room you can use an edit view for 'rooms'.
And you have to be a participant in that room. For that, you can create an edit view for participants with selects for user and room. Let me know if it does not work
@christianhugoch Thanks for that.
I think I have it working. However messages are NOT in Real-time! And a refresh of the room view webpage is required for new messages to appear.
Are you able to test if that is the case for you? If not, maybe I have done something wrong and you could share your backup file?
And what does the "Participant max read id field" do?
If I try to use it I just get a error when loading Room view webpage.
Hi, could it be that you're behind a nginx or so. The chat uses websockets and I believe the default nginx config isn't ready for that. Can you open your browser console and see if there are any errors like 'unable to connect to ...' ?
I'll take a look at the Participant max read id field
@christianhugoch I am not using nginx or or anything. I just have a local VM running as a test bed for development.
However! I do get an error.
Does this help identify the problem?
No, I think that's another problem. Are you using the chat with different users, or is it at both sides the same?
Different user, I even tried to use Chrome on a different device (for different user), but was same result.
Hm, can you open the NetworkMonitor and send me a screenshot of it after you load the page and after sending a message.
@christianhugoch I hope this is the NetworkMonitor you were talking about.
Before Message
After MEssage
Hope this helps.
Did you want me to send you the backup file?
Yes, could you send me the file? I've just tested the unit test setup on my device, and I believe your screenshots are looking good, too.
@christianhugoch I've emailed you the backup file to your Gmail address.
Let me know how you go.
Hi, I've tested it between firefox and chrome and it worked. Let think about it what else could be wrong here.
@christianhugoch Hmm interesting. Thanks for letting me know.
I have now tried it with two different VM's (with update), between different browsers (Chrome Firefox), different computers and still the same problem, no live update.
How are you running (hosting Saltcorn)? What version of Saltcorn are you running? I'm currently running VM's (Ubuntu 20.04) using Hyper-V.
I am getting this error in Chrome:
Is there some Firewall rule preventing Websockets?
Any suggestions on what else it could be?
I'm running saltcorn on my host os with the cli command: saltcorn serve
I would like to see if your process has logs. You are propably using a systemctl service, right? Can you do
systemctl status saltcorn
@christianhugoch Yes I'm using systemctl service.
This is what I get.
Can you go to 'About application / development'
and enable 'Log SQL to stdout', 'Log client errors'?
Perhaps we have to add more debug logs to see what's going on.
@christianhugoch I don't know enough about Linux to understand what you mean there or how to do that.
Are you able to provide actual Linux console commands? or more detailed instruction on how to enable logs?
That's not a Linux cfg, it's just a tab on the dashboard.
Click 'About application', then next to 'Mobile App' is the 'Development' tab.
Here you can activate Log SQL to stdout and Log client errors
Then use the chat and do systemctl status saltcorn or perhaps try journalctl -u saltcorn
I'm just fishing, but do you have some special extensions installed in your browser?
@christianhugoch Ah! got it! No. I'm not running any extensions etc, got a fresh install of Firefox and event tried with Chrome incognito mode.
Ok, here is the result for systemctl status saltcorn after enabling Log SQL to stdout and Log client errors in saltcorn settings.
And journalctl -u saltcorn
Hope this helps.
@christianhugoch I have now tested the Chat feature with the Mobile App!
And I got the same result as with using the Browser, New messages don't load unless I reload (leave and join the chat room again).
Are you able to test Chat in a Ubuntu VM? Because I'm totally lost why it doesn't work for me. I even reinstalled a fresh VM and Ubuntu 22.04 with all updates etc, and still no go.
On the Upside, with the new version 0.8.9 and the new Toasts: notification system that has been redesigned. The "Welcome to Saltcorn" pop up that happens when App first opened is no longer an issue and it doesn't cause the page content to shift in the mobile App. However it still says "Welcome to Saltcorn!" with no way of changing it. So I will raise a feature request for that.
Hi, I overlooked your screenshot (from last week) with the Websocket connection to ... failed error.
The problem has to be there, I'll try to re-create
@christianhugoch Here is the interesting thing.
After I created a fresh new VM with Ubuntu 22.04, I no longer get ANY Errors in Chrome.
However, I still a warning while testing in Firefox.
Hope that helps, additionally could there be any Firewall setting in Ubuntu preventing Websocket's connection?
Okay, I can replicate a problem. When I run the VM with a Network Bridge then it does not update on my host. Not sure if this is the same problem but I can look further into it.
@christianhugoch Yes! I use a network Bridge with my Hyper-V.
I will try some other VM software without a bridge and see how it will go.
@christianhugoch I have now tried using a VM in VirtualBox with Bridge and NAT and in both cases I could not make Live Chat work, no matter which ports I forwarded. Even tried Disabling Ubuntu Firewall.
The closes solution I could find was this: https://stackoverflow.com/questions/45894011/virtualbox-socket-hangup But I don't know how to change the Websocket address in Saltcorn.
I am going to try using a VM on a Type 1 Hypervisor (Proxmox) next.
Okay, sorry I haven't yet looked deeper into it, but I definitely saw it working with a DigitalOcean droplet on the web and in the app version.
@christianhugoch I have now tried Live chat without ANY VM, just bear metal Ubuntu install with Saltcorn on an old PC.
And still live chat does not work...
Could Live Chat feature be gated unless SSL certificate is used??
Is there a way for me to get Saltcron to run as HTTPS? without using SSL certificate from Let's Encrypt?
Apologies for letting you wait.
I think you could set up a nginx server with your own certificate and a DNS server so that you don't have to use an IP. But that's probably way too much effort.
Socket.io doesn't insist on HTTPS, you can test it on the localhost with HTTP, but when I open the page via an IP with HTTP on the VM, then I get a warning that the connection is not secure. I believe this is why the server can't send a notification to your browser. I debugged the server a bit on the VM, and he does all the right things, only the message doesn't arrive at the browser.
I believe this is just a problem you get in a local test environment with a VM that you have to access via IP. So in a production environment where all is set up, this shouldn't happen, and I think this is more importan. But I'm still trying to find a workaround or something.
@christianhugoch Apologies for late reply.
Thank you for letting me know, I will try nginx server with my own certificate or maybe ill try with Cloudflare for a more production ready example.
Will let you know.