[Solved] Multi-terminal / Message Server woes?

On the server, I shut down SambaPOS and stopped the Message Service. The client still indicates it is connected (green Connected indicator at bottom left).

That can’t be right. I expect it to switch to Not Connected, but it does not. How can I trust the indicator now?

I just submitted an Order via the client, and TCPView went mad with retries to port 9898 (the port I configured for Message server), and finally the indicator went red and said Not Connected.

Fired up the Message Service, and see this…

###Client

###Server

So it appears from TCPView that messages are being sent from the Client and received by the Server, yet the server Entity Screens do not update.

If I submit an Order via the Server, I see no communication occurring via TCPView.

Do I need to start the client on the Server as well?

EDIT: Yes, that is it. The Message Client needs running on both the Server and the Client.

I guess that makes perfect sense. :stuck_out_tongue_winking_eye: Everything is working now! :smiley: And I just gotta say… man that is slick! Very cool. And fast, even on my WiFi (no interference or other users at home here though).

EDIT2: I was able to remove all automation regarding Broadcast Message, Message Received, and Widget/Screen Refreshes. It still works without any of that.

###Server

###Client


Now off to figure out how to get my Firewall back on…

1 Like

You can add the actual sqlserv exe and it will enable the service under the firewall.

Tried that and still no go…

For my testing, the server is running on Win 7 x64 and SQL Express 2014 x64.

The Client is running Win 8.1 32-bit.

Tests are being done via WiFi.

Strangely enough, from the Client, the UDL file connects without issue when I use SQL Native Client 10, but not when I use MS OLE for SQL). But SSMS (32-bit) and SambaPOS (32-bit) cannot connect unless I turn off the Firewall on the Server. The OLE Provider works fine then too.

Hmm… came across an article that says I need to open UDP 1434 for SQL Browser.

Removed SQLSERVR.exe from the program list, and re-enabled inbound Rule for TCP 1433 which I had set up before.

Added another inbound Rule to allow UDP 1434.

Seems to be working for DB connection.

Does my Message Server still work on 9898? EDIT: Yes, it appears to be working too.

So to recap…

##Server

On the Server, where SQL Express is installed, ensure these Services are running:

  • SQL Server
  • SQL Server Browser
  • SQL Server VSS Writer (not required for remote connections, but needed for DB Backup/Restore etc.)


Create Inbound Rules in Windows Firewall to allow access to required Protocols/Ports:

Control Panel > Windows Firewall > Advanced Settings > Inbound Rules > New Rule...

  • TCP 1433
  • UDP 1434
  • TCP (choose a Port for Messaging Service)

Inbound Rule for Messaging Service…


Using SQL Server Configuration Manager, enable TCP/IP connections under SQL Server Network Configuration > Protocols for [SQLEXPRESS], and set a Static TCP Port (1433) for the IP of the Server. Also, it is suggested to delete the 0 in the TCP Dynamic Ports field.


Run the Messaging Server Service Tool on the Server to install the Messaging Service as a Windows Service so that it starts when Windows starts. You can use it to update the Port you want to use as well.

C:\Program Files (x86)\SambaPOS5\Samba.MessagingServerServiceTool.exe

Check the SambaPOS MessagingServer Service Logon options and use an Administrator Account …


Ensure you have Terminals defined in SambaPOS for each Terminal (including the Server).

Manage > Settings > Terminals


Configure the Server to use the “Server” Terminal name, and set the Message Client to auto-start. Since this is the main Server, you can use the following for the Message Server Name:

Manage > Settings > Local Settings

  • name of the computer (i.e. http://SERVER-PC)
  • http://localhost (local loopback name)
  • IP address of the server computer (i.e http://192.168.0.200)
  • http://127.0.0.1 (local loopback IP address)


##Client

There are no special settings that need to be made in Windows for the Client Terminals. For example:

  • no need to mess with the Firewall
  • SQL Express does not need to be installed, so there are no services to check on (we will configure SambaPOS to connect to the database on the main Server Terminal)
  • Messaging Server Service should not be running or installed (no service to check)

Ensure your Local Settings are configured properly for this Terminal.

Manage > Settings > Local Settings

  • select the name that will be used for this Terminal (every terminal must use a unique name)
  • set the Connection String to connect to the Database on the Server
  • set the Message Client to auto-start, and set the Message Server Name to the IP address or Computer Name of the Server (ie. http://JVSERVER)

4 Likes

Can’t believe you’ve never felt with multiple terminals before :smile: nice to see even long time pros get stuck :-p
Thanks for the firewall details, have really struggled in the past and not really understood what I did to sort, this is book marked for next time :slight_smile:

@QMcKay HAHA yes it solved my isues too before msg server connects when you logon to sambapos now its connects automatically this helped me thanks bookmarked too. Now I need to work how the msg server works through network over internet as I can use pos but not msg server.

Msg server not meant to work over Internet.

@kendash Ok Thanks for the info but also those settings solved my long time firewall issue as I was only able to connect to client when firewall turned off but QMcKay screen shots solved my issue now I can connect even firewall on through port . thanks community.

1 Like

Found this Powershell Script. Should make things easier.

Copy/paste the script into Notepad (or similar) and save the file as: fw.ps1

function isFirewallPortOpen {
    param( [int] $port )
    $fw = New-Object -ComObject hnetcfg.fwpolicy2 
    if ($fw.Rules | Where {$_.LocalPorts -eq $port }) {
        return [bool]$true
    } else {
        return [bool]$false
    }
}

function existsFirewallRule {
    param( [string] $name )
    $fw = New-Object -ComObject hnetcfg.fwpolicy2 
    if ($fw.Rules | Where { $_.Name -eq $name }) {
        return [bool]$true
    } else {
        return [bool]$false
    }
}

function addFirewallRule {
    param(
        [string] $name,
        [int] $port,
        [int] $protocol
    )
    $fw = New-Object -ComObject hnetcfg.fwpolicy2 
    if (isFirewallPortOpen $port -or existsFirewallRule $name) {
        Write-Host -ForegroundColor:Red "**Rule Already Exists or Port Already Open."
    } else {
        $rule = New-Object -ComObject HNetCfg.FWRule

        $rule.Name = $name
        $rule.Protocol = $protocol
		# NET_FW_IP_PROTOCOL_TCP = 6
		# NET_FW_IP_PROTOCOL_UDP = 17
        $rule.LocalPorts = $port
        $rule.Enabled = $true
        #$rule.Grouping = "SambaPOS Multi-terminal"
        $rule.Profiles = 2
		# NET_FW_PROFILE2_DOMAIN   = 1
		# NET_FW_PROFILE2_PRIVATE  = 2
		# NET_FW_PROFILE2_PUBLIC   = 4
		# NET_FW_PROFILE2_ALL      = 7
        $rule.Action = 1 # NET_FW_ACTION_ALLOW
        $rule.EdgeTraversal = $false

        $fw.Rules.Add($rule)
        Write-Host -ForegroundColor:Blue "A rule named '$name' has been added to Windows' Firewall."
    }
}

addFirewallRule -name:"SambaPOS SQL Traffic" -port:1433 -protocol:6
addFirewallRule -name:"SambaPOS SQL Browser Traffic" -port:1434 -protocol:17
addFirewallRule -name:"SambaPOS Messaging Server" -port:9898 -protocol:6

The last 3 lines of the script execute to add 3 Inbound Rules to the Firewall. Change the name of the Rule or the port if desired.


Open a Command Prompt as Administrator and navigate to the location of the fw.ps1 file. In the Command Window, type the following to execute the script:

powershell -executionpolicy bypass -File fw.ps1

This screenshot shows what happens when it is successful, and what happens if it is run when the Rule or Protocol/Port already exist in the Firewall.

And here, we see 3 Rules have been created:

2 Likes

Hmm… @emre, what do I need to do to make Terminals aware that a Workperiod has been opened or closed?

My setup uses the Start Workperiod and End Workperiod Actions.

On the main server Terminal, when I start or end a WP, the clients are not aware of this change…

The Nav Screen POS Tile does not update to reflect {SETTING:ISCURRENTWORKPERIODOPEN}, and it’s operation (clicking on it) does not behave as expected.

For example, if the WP was open and I close it on the Server, I can still click on the POS button and start creating a Ticket.

Vice-versa, if the WP was closed and I open it on the Server, when I click on the POS button on the Client, it does not respond (it thinks the WP is still closed).

Thanks for reporting. It will work fine on next update (.56).

2 Likes

Workperiod update issue Confirmed Fixed in 5.1.56 … thanks again @emre!

Ok, am strugling with firewall.
Diasable firewall and all works ok.
Have added the rules but must be missing something;

1 Like

Sorry. seem to have got it, didnt specify a TCP port for SQL…

Hi all,

I’m a new Samba user and so far it’s been fun learning the different functionality of the software.

I have one issue with the message server, where the server terminal’s table button colour is updated after the the client terminal made the order but the client terminal’s colour isn’t update when the server makes the order. Does anyone have any idea what might have caused this?

@QMcKay thanks for the detailed recap write-up on the server/client setup.

You don’t have message server setup properly, that’s the reason your entity (table) state is not updating properly across terminals. Double check again the setup above, including your firewall setup. If you are using a third party firewall (not Windows built in) you will have to also make changes to that.

1 Like

One more stumbling block that I think could affect connectivity…

Check the Network Profile Settings for your current connection for both the Server and Client machines. They should all be set to Home/Work/Private. If they are set to Public on any of your machines, then you need to change that…

#Network Profile Settings

##Windows 10 / 8

##Windows 7

##Change Network Profile Windows 10 / 8

  • click on Network Icon at the lower-right of your screen near the Clock.
  • click Network Settings
  • click Wi-Fi or Ethernet (if you have a wired network)
  • click Manage Known Networks
  • select the Network you want to change and click Properties
  • change the setting for “Make this PC discoverable
  • On : Private
  • Off : Public

##Change Network Profile Windows 7

  • click on Network Icon at the lower-right of your screen near the Clock.
  • click Open Network and Sharing Center
  • click on the blue link below your Network
  • select Work Network
  • click Close

###Reference:


#Firewall

The easiest thing to do to check if you have a Firewall problem is to simply disable the Firewall and see if your State Updates work in SambaPOS. If it works when the Firewall is disabled, then you know positively that your Firewall is blocking communication.

Here is my latest version of the Powershell script - the last 3 lines are the important ones that will set up the Rules for the ports …

##fwrules.ps1###

function getRule {
    param(
        [string] $name
    )
    $fw = Get-NetFirewallRule -DisplayName "$name" -ErrorAction:SilentlyContinue
    if ($fw) {
        return [bool]$true
    } else {
        return [bool]$false
    }
}
function setRule {
    param(
        [string] $name,
        [string] $port,
	[string] $protocol,
	[string] $profile
    )
    Set-NetFirewallRule -DisplayName "$name" -Action "Allow" -Direction "Inbound" -Enabled "True" -LocalPort "$port" -Profile "$profile" -Protocol "$protocol" -Verbose
}

function addRule {
    param(
        [string] $group,
        [string] $name,
        [string] $port,
	[string] $protocol,
	[string] $profile
    )

    $fw = getRule("$name")
    if ($fw) {
	Write-Host -ForegroundColor:Black -BackgroundColor:Magenta "`r`n*** Rule already exists, Modifying Rule: '$name' ..."
	setRule -name:"$name" -port:"$port" -profile:"$profile" -protocol:"$protocol" -Action "Allow" -Direction "Inbound" -Enabled "True"
    } else {
	Write-Host -ForegroundColor:Black -BackgroundColor:Green "`r`n****** Adding Rule: '$name' ..."
        New-NetFirewallRule -Group "$group" -DisplayName "$name" -Action "Allow" -Direction "Inbound" -Enabled "True" -LocalPort "$port" -Profile "$profile" -Protocol "$protocol"
    }

}

addRule -profile:"Private" -protocol:"TCP" -port:1433           -group:"Custom Rule - SambaPOS Multi-terminal" -name:"SambaPOS SQL Traffic"
addRule -profile:"Private" -protocol:"UDP" -port:1434           -group:"Custom Rule - SambaPOS Multi-terminal" -name:"SambaPOS SQL Browser Traffic"
addRule -profile:"Private" -protocol:"TCP" -port:9000           -group:"Custom Rule - SambaPOS Multi-terminal" -name:"SambaPOS Messaging Server"

And here is a BAT file to execute the Powershell script. Right-click and Run as Administrator. The 3rd line is the important one. You could also open a Command Prompt (Admin), navigate to the location of fwrules.ps1, and execute line 3.

##fwrules.bat##

D:
CD D:\Programs
powershell -executionpolicy bypass -File fwrules.ps1
pause

This is the Output when the Rules are successfully added:


This is the Output when the Rules are already existing:


And here you can see the Firewall Inbound Rules that the script created:

6 Likes

Thanks for the pointers, @QMcKay. I will give these settings a go.