
As above and also, I would not stand talking to them for any length of time while you get to the bottom of it. Often in such a situation with a worried dog, the dog will be able to cope with a short encounter but as the encounter gets longer, they become more stressed with being unable to leave until as you've seen, that stress gets the better of them and they react. So better to just say hello then carry on, so he doesn't find himself trying to deal with more than he can cope with.
Pair these brief encounters with something he likes (meaty treats often work well) and you'll be starting to make them a source of something pleasant, rather than stress.